Question

How to derive a user parameter from another user parameter in a custom transformer?

  • 8 March 2022
  • 5 replies
  • 11 views

Badge +1

I have a simple FME 2021.2.1.0 workspace which isn't very usable - its just for giving a simple example:

 

main workspace 

My custom transformer looks like this:

 

Custom transformerI am trying to create the custom transformer so that it takes one user parameter from the main workspace and use it for the bufferer. I would like the Anchored Snapper to use a fraction (10% as an example) of the my_value user parameter as the Snapping Distance.

 

The problem is that the Anchored Snapper can only use a hard coded value or a user parameter as input.

 

In the custom transformer I can create a "Number" user parameter but I cannot assign it the my_value user parameter and multiply it by 0.1.

I can create a scripted python user parameter but when I use FME_MacroValues['my_value'] to return a new value FME_MacroValues['my_value'] just returns "$(my_value)" (I guess it needs to be dereferenced somehow?).

 

I can create another user parameter in the main workspace and give it to the custom transformer, but that concept could possible lead to lots of "local" variables needed to be defined "globally".

 

What could be a better solution?

 

Regards, Casper

 


5 replies

Badge +4

Hi @Casper Børgesen​, here are some people which have the same problem. It will not help you directly, but safe look on it:

AC Idea: Snapping Tolerance for AnchoredSnapper (safe.com)

Badge +1

Hi @Casper Børgesen​, here are some people which have the same problem. It will not help you directly, but safe look on it:

AC Idea: Snapping Tolerance for AnchoredSnapper (safe.com)

Its probably a good idea, but it doesn't help me with the fact, that part of my problem is creating a user parameter based on another user parameter inside a custom transformer.

Userlevel 3
Badge +16

Its probably a good idea, but it doesn't help me with the fact, that part of my problem is creating a user parameter based on another user parameter inside a custom transformer.

The problem is exactly as you said: "The problem is that the Anchored Snapper can only use a hard coded value or a user parameter as input."

If you try with a different transformer, like NeighborFinder in the custom transformer and create a parameter there for the max distance. Outside on the main workspace, that maximum distance parameter can be assigned to a calculated value based on another parameter, exactly as you want. This may be your best bet, to replicate snapping with the result from the NeighborFinder.

So, it's a little counterintuitive that how the parameter is used can constrain how its value can be set. To reinforce that idea, inside the custom transformer use that anchored snapper tolerance parameter in an attribute creator and then delete the anchored snapper. Suddenly that parameter can be assigned a calculated value from the main workspace.

Userlevel 4
Badge +25

Just to mention, the reason the AnchoredSnapper cannot take an attribute value, is that tolerance can't be different for two different features.

 

For example, two vertices are 5m apart. If one has a tolerance of 4m and the other vertex has a tolerance of 6m, then should they be snapped together?! That problem can't happen if we make it a fixed value.

 

I guess we might implement something to set rules on what would happen in that scenario, but that's in the future for sure.

Badge +1

Just to mention, the reason the AnchoredSnapper cannot take an attribute value, is that tolerance can't be different for two different features.

 

For example, two vertices are 5m apart. If one has a tolerance of 4m and the other vertex has a tolerance of 6m, then should they be snapped together?! That problem can't happen if we make it a fixed value.

 

I guess we might implement something to set rules on what would happen in that scenario, but that's in the future for sure.

Hi Mark, that makes sense. Luckily for me I don't want to work with a variable snapping tolerance. If you see my main workspace, I have a user parameter set to 10. That parameter is provided to the custom transformer as a user parameter of type number and I would just like to create a user parameter in the custom transformer that has the value "my_value" * 0.1. As far as I see it that makes the "my_value" * 0.1 constant and thus a very suitable value for the AnchoredSnapper. But I can't find a way to create that value.

Reply