Support Forum

[Frage] How to change ref_x value in code? SMARTPARTS! [Gelöst]

Schlagworte:
  • Smartparts
  • Ref_x
  • Plugin-Download

I have a problem changing ref_x in code as follows:

I_ROW `Length`
VALUES "WallLength" RANGE [0.1, 100]
I_INFIELD "WallLength" , DlgWidth, CurRow, CtrlWidth, CtrlHeight
ref_x = WallLength

Ref_x assignment cannot be remembered and is simply ignored. There are cases when you cannot just read ref_x value with I_INFIELD command where it is remembered. But rather you would need to assign Ref_x a custom value!
Is any solution that this can be achieved?

Primoz

Lösung anzeigen Lösung verbergen

If this topic is solved, please click on "Is solution" button in the message with the solution.
This could help other users...


Hello,

You have to "apply" the assignment.
Add this:

PARAMETERS REF_X = REF_X

So, the value will be saved.


Hi thanks,
but this code does not do it visually!

DIALOG SCRIPT:
I_PALETTE `Test`,3, 120
I_SECTION `Geometry`,0
I_ROW "Geometry",1
I_ROW `Length`
VALUES "WallLength" RANGE [0.1, 100]
I_INFIELD "WallLength" , DlgWidth, CurRow, CtrlWidth, CtrlHeight
PARAMETERS REF_X = WallLength
I_SECTION_END

3d SCRIPT:
id=1
HANDLE_ 0 , 0 , 0 , id , "REF_X" , 1
HANDLE_ REF_X , 0 , 0 , id , "REF_X" , 2
HANDLE_ -REF_X , 0 , 0 , id , "REF_X" , 3

BOX ref_x ,ref_y,ref_z

When I first run the code, I change the WallLength parameter and nothing is changed on screen with the box. But when I click and edit smart part, the value is changed numerically.Whatever value I change, nothing is changed on real object on screen, just a variable is changed.
If I change object with grip, again object is not compatible with numeric value. Something here is not working. I create very simple example where I just want to draw a box and change the value numerically and control it with one grip in x direction, but obviously it is a bug here or I do not see something.
Any help would be welcome.
Primoz

Short code snippet:
https://www.dropbox.com/s/xw7y7q4ot8x473d/Test.smt?dl=0

Variable is not compatible with visual box representation. Here should be some tricks to achieve that variable ref_x is drawn correctly in 3D script and grips are compatible with this value as well.
Maybe sth is not written correctly in this code?

First, you did not what I explained:

REF_X = WallLength
PARAMETERS REF_X = REF_X

First line assigns the value to the variable. The second one stores it as parameter in the "memory" of the SmartPart.

But if you use a variable (WallLength), there is no need to transfer the value to REF_X.
You can directly use WallLength for the X value of your box (BOX WallLength, REF_Y, REF_Z).
And so, the Handle function must be for WallLength and not for REF_X.

Usually, VALUES functions must be in the Parameters script.


Hi Bertrand,

thank you very much for your suggestions. It works far better with parameters in 3D script drawing objects and creating handles as well. That way everything is controlled with parameters what is by far the easiest way.

Thanks, Primoz

If this topic is solved, please click on "Is solution" button in the message with the solution.
This could help other users...