Is there a way to tell a dynamic component to use a current valor? For instance, lets imagine that we make a condition where in one case its the result of an equation, in the other case I would like the to use the X position in the world.
So, in other words;
=IF(Test = 1 , equation , CURRENT X)
Tell me if you have any equation or If Im being unclear.
I am not sure what you want specifically, but you could reate a custom attribute called ‘Return_X’ say.
In the input box you could add =CURRENT(“X”)*2.54
Then it could go something like so:
=IF(Test=1,(equation,Return_X)
Maybe if you share the model or provide images then somebody could take a look at it further.
Wouldnt that be a circular dependency? It is related to a project Im working on but I dont have an exemple as I dont think the function exist.
Let me try to rephrase what I meant. Lets say I have an equation that place a component on the X axis, but I also want to be able to use its current location in a condition. But the thing is, the current location is a variable and cannot be solved by using a static number or an equation. I actually need to be able to pull the current X location from the world. Because I think if I use your suggestion, it will constantly pull the updated location and never actually use the actual location.
Alternatively, as another entirely different problem. I tried to check if the parent module was there(the blue square, should return an error since the parent component was exploded away), hoping that when I explode the whole module once(there are about 4 layers of components) it would create an error in the slot and by default set it to zero. But it doesnt seem to work that way it looks like it keeps the result of the equation even though the parent object is no longer part of the dynamic component…
In other words, any ways to check if a component is there or not?
What Im trying to achieve with that whole “current” and “checking if a component is still there” is if someone decide to explode my dynamic component and change something in it using the options already available, it send it back to a faulty X position because it used copies in its equation and said copies are no longer part of it.
I support Ashley on this, first as you using metric, current should be followed by *2.54 as previously advised.
For a circular reference an error will appear.
A model helps, we can only guess
My guess is that you require a redraw of the example for it to update the DC.
This is the same for children to update a parent after say a FaceArea() calculation. Sometimes there is no automatic redraw, so scaling can get out of sync with the size values, Redraw corrects this. Depending on the scope of your project and how you share it, you may consider a shortcut or some ruby scripts to build on the shortfalls of your DC creations, like Tig’s “Redraw all” one liner linked to a button
Ok I will try that, but I dont understand why I have to add 2.54(where does that number come from?) for “current” to work? I added it as showed < =CURRENT(“X”)*2.54 >, it still return zero despite the X being another valor.
I will look up tig’s redraw all maybe it will indeed fix some of my problems, or open up other possibilities.
Thanks for the help!
PS: Not sure where to find “tig’s redraw all”. Im looking but if you ever come across this before I find it.
Edit: You must be talking about that scrip?
Sketchup.active_model.selection.grep(Sketchup::ComponentInstance).each do |s|
$dc_observers.get_latest_class.redraw_with_undo(s)
end
But in that case you need the dynamic component selected, so you must be talking about another script that does this but for everything?
The redraw() can be activated via the onclick() function, or use right click context menu, dynamic components, redraw; a shortcut could be assigned to this
True, that snippet is for the selection, but the size of the selection is of your choosing, so control “A” selects everything.