Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Update parameters programmatically.

Anonymous
Not applicable
Hi! How update parameters programmatically? Is it possible?
e.g.
if (scaleValues=1)  then !Scale with plan
	Text2 0,1, "Scale with plan"
	Parameters LastScale=0
	LastScale=0
endif

if (scaleValues=0)  then !Scale independent
		Text2 0,1,LastScale
			if ABS(LastScale-GLOB_SCALE)>0 then
				parameters LastScale=GLOB_SCALE 
				LastScale=GLOB_SCALE 
			endif
		Text2 0,2,LastScale
Endif
Thank you!
16 REPLIES 16
Ralph Wessel
Mentor
Beart wrote:
Hi! How update parameters programmatically? Is it possible?
Yes, that's no problem. I haven't tested your code snippet, but it looks OK. Just make sure it is part of the Parameter script. The parameters command will only work in certain contexts, e.g. in response to editing.

Tip: Either type GDL commands in all lower case or all upper case, but don't use both or (worse still) mixed case. The latest standard recommends all lower case. Consistency makes for good reading, which will make your life easier.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
OK, Ralph. Thanks!
Ralph wrote:
Yes, that's no problem. I haven't tested your code snippet, but it looks OK....
But it does not work…Can you tell me correct code when object rescaling(Scale independent)?
Ralph Wessel
Mentor
Beart wrote:
But it does not work…Can you tell me correct code when object rescaling(Scale independent)?
I'm not sure what you're aiming to do, but all you need is something like this:
if (scaleValues) then !Scale with plan
	mul2 GLOB_SCALE, GLOB_SCALE
endif
rect2 0, 0, a, b
if (scaleValues) then
	del 1
endif
The above code draws a box either to the literal object width/depth, or optionally multiplies it by the current scale remains the specified size on the printed sheet.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
I need a Request, (operator, macros-maybe) for "auto-update" the parameters.
Ralph Wessel
Mentor
Beart wrote:
I need a Request, (operator, macros-maybe) for "auto-update" the parameters.
You don't need this. ArchiCAD will automatically run the object's 2D script whenever the scale changes.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
OK. Ralph. Look at this object "Bow" and Scale it independent (Paper Size), please.
!============================= 
! Parameters
A=1000
B=1000
tx=1000 (length)
ty=1000 (length)
!===============================
!Parameter Script
values "ty" range (0,]
values "B" ty,  -ty
values "A"  range (0,], range [,0)
values "tx"  range (0,]
!===================================
!2d Script
unID=1
hotspot2 0, 0, unID, A, 1+128, A:	unID=unID+1
hotspot2 1, 0, unID, A, 3+128, A: unID=unID+1
hotspot2 -A, 0, unID, A, 2, A: unID=unID+1
hotspot2 0,B
if symb_rotangle>89.999 and symb_rotangle<269.999 then
	rot2  180
	hotspot2 0, -ty, unID,  tx,  1+128   : unID=unID+1
	hotspot2 -tx+unit0, -ty, unID,  tx,  2    : unID=unID+1
	hotspot2 1, ty, unID,  tx,  3    : unID=unID+1
	hotspot2 -tx+unit0, 0, unID,  ty,  1+128   : unID=unID+1
	hotspot2 -tx+unit0, -ty, unID,  ty,  2    : unID=unID+1
	hotspot2 tx+unit0, 1, unID,  ty,  3    : unID=unID+1
	else
		hotspot2 0, ty, unID,  tx,  1+128   : unID=unID+1
		hotspot2  tx, ty, unID,  tx,  2    : unID=unID+1
		hotspot2 -1, ty, unID,  tx,  3    : unID=unID+1
		hotspot2  tx, 0, unID,  ty,  1+128   : unID=unID+1
		hotspot2   tx, ty, unID,  ty,  2    : unID=unID+1
		hotspot2  tx, -1, unID,  ty,  3    : unID=unID+1
endif
del top

line2 0,ty,tx,ty
line2 0,0,0,ty
line2 0,0,-A,0
line2 -A,0,tx,ty
Ralph Wessel
Mentor
Beart wrote:
OK. Ralph. Look at this object "Bow" and Scale it independent (Paper Size), please.
Before going any further, can you explain what you are trying to accomplish, i.e. what should this object do and how does it interact with the user?
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Ralph wrote:
Before going any further, can you explain what you are trying to accomplish, i.e. what should this object do and how does it interact with the user?
Look at animated gif-pictures.
Ralph Wessel
Mentor
Beart wrote:
Ralph wrote:
Before going any further, can you explain what you are trying to accomplish, i.e. what should this object do and how does it interact with the user?
Look at animated gif-pictures.
OK, I think you are trying to make an object that is based on a fixed size (on the printed page), but can be stretched on screen (using the active units/scale).

The key to this is realising the most important parameter is the size of the object on the printed page. When you display the object in 2D, the output size (and the position of the hotspot positions) is determined by multiplying this figure by the current scale. If the user resizes the object, you need to recalculate the size on the printed sheet by dividing the size in the model by the active scale. And - relating to your original question - this calculation should be done in the Parameter script, using the GDL parameter command to ensure the change is permanent.
Ralph Wessel BArch
Software Engineer Speckle Systems