Dynamic component problem(s)
-
Hi guys, I stumbled upon some problems today. I'd appreciate if you have any suggestions about what can i try:
-
a simple dynamic component - i'd like to contstrain the length to be between eg. 10 and 20 units. I tried using some logic functions (like IF etc.) but ended up with circular reference errors.
-
global variable - i'd like to add to a global variable a certain value on each creation of a dynamic component, substract when the component is deleted, and modify the global variable if some attributes of the component are changed. I'd like the user to be able to easily monitor the current value of the variable, by showing it in a corner of the model view (or somewhere else). I looked for "oncreate" event or similiar, but components attribute window shows only "onClick".
-
-
#2 there is no way to do that built into DC's. You could possible write a ruby script that could do it for you by adding some functionality to the DC's. But anyone that wanted to yuse your DC's would have to install your script also.
#1 is do-able though. There are some example DC's available to look at. I don't recall which one would be the best one to check out though. But it is possible,
Chris
-
Hi
For #1 i tried LenZ=LARGEST(SMALLEST(CURRENT("LenZ"),20),10) ...it works...kind of...it limits the size, but it mess up with the position and all sizes in between the limits. Any idea why?
#2 - I see
-
I attached the file, just try to scale it using scale tool and you'll see.
The other problem is that typing any value in the Length field erases the component attributes LenZ formula completely
-
You should be able to accomplish this using a couple IF expressions. I used a cz variable to simplify the IF expression:
cz: =current("LenZ")
Then used this to set the Z length:
LenZ: =if(cz > 300, 300, if(cz < 160, 160, cz))
The gotcha is that you may need to make sure all the units of the formulas and variables are the same.
-
@jim said:
You should be able to accomplish this using a couple IF expressions. I used a cz variable to simplify the IF expression:
cz: =current("LenZ")
How do you put the variable assignment into the component attribute formula ?
Don't you need a script for that ? -
Well, you click "Add Attribute" and type in the variable name:
Here's what I ended up with after making some refinement:
-
Thanks for the tip. However, i discovered that the problem is (i suppose) not due to the formula, but because of the units returned by current("LenZ") which are inches, as opposed to what i use in the formula and all other variables - centimeteres. Model default units are decimal too.
After i "adjusted" cz with simple "*2.54" (is there any function i can use to make SU convert units "internally") it started to work and continued to do so for the next minute. Then it got messy again. Why - i don't know.
-
There does appear to be something wrong - the value returned by CURRENT("LenZ") is in inches although the .
Multiplying by 2.54 should work, so I am not sure why it got messy for you - it is working well for me.
-
Hi,
I typed what i showed exactly and it works now. I think the reason was either the formula that used largest/smallest or using constants istead of variables, though what's the difference - i dunno.
Thanks for the tip.
Last one thing that seems unsolved is how can i make the length parameter editable for the user (eg. if he/she wanted to type in the value) without erasing the formula ?
Advertisement