GDL
About building parametric objects with GDL.

VALUES and Model View Options

Mathias Jonathan
Advocate

I'd like to create an object with A=B and 2 values for A and B: 1 or 2.

If A(or B) = 1 then it draws a square.
If A(or B) = 2 then it draws a circle.

 

 


In addition to this (simple) object, I'd like to be able to set offset hotspots on the circle and square (to force the user to take some safety margins in the drawing without cheating on the circle or square actually drawn).

These hotspots are offset by a "dim_secu" value.

I'd like to be able to modify this "dim_secu" value via Model View Options.

Capture d’écran 2023-11-28 à 16.53.47.png

 

This is where I get stuck.

 

The dim_secu value is correctly updated in the object: the displayed A value takes this new value into account, but the drawing itself doesn't update on its own: I have to force this update manually.

 

Capture d’écran 2023-11-28 à 17.02.56.png

If I don't use Model View Options and change dim_secu from the object itself, I don't have this problem.

Any ideas on how to debug the object?

Thanks in advance! 

 

 

Principal:

 

succes = LIBRARYGLOBAL ("MVO_EXAMPLE", "dim_secu_glob" , dim_secu)	

 

 

2D:

 

! ---------------------------------------------------------------------- !   
! --------HOTSPOT------------------------------------------------------- !   
! ---------------------------------------------------------------------- !   

_unID = 1

	HOTSPOT2 0,		0, _unID			: _unID = _unID + 1

	!!! ------------ Coins : Dimension A
	hotspot2  0, 0, _unID, A, 1+256,A ! base ancrage
	_unID = _unID + 1
	hotspot2 -1, 0, _unID, A, 3,A     ! ref
	_unID = _unID + 1
	hotspot2  A, 0, _unID, A, 2,A    ! move
	_unID = _unID + 1

	
	hotspot2  0, B, _unID, A, 1+256 ,A 
	_unID = _unID + 1
	hotspot2 -1, B, _unID, A, 3 ,A 
	_unID = _unID + 1 
	hotspot2  A, B, _unID, A, 2 ,A
	_unID = _unID + 1  
	
	!!! ------------ Coins : Dimension B
	hotspot2 0,  0, _unID, B, 1+256 ,A
	_unID = _unID + 1
	hotspot2 0, -1, _unID, B, 3 ,A  
	_unID = _unID + 1  
	hotspot2 0,  B, _unID, B, 2 ,A    
	_unID = _unID + 1
	
	hotspot2 A,  0, _unID, B, 1+256 ,A
	_unID = _unID + 1
	hotspot2 A, -1, _unID, B, 3 ,A    
	_unID = _unID + 1
	hotspot2 A,  B, _unID, B, 2 ,A
	_unID = _unID + 1   




! ---------------------------------------------------------------------- !   
! --------DESSIN 2D----------------------------------------------------- !   
! ---------------------------------------------------------------------- !  



IF A=1+2*dim_secu THEN
RECT2 dim_secu,dim_secu,A-dim_secu,B-dim_secu
ELSE
CIRCLE2  A/2,A/2,(A-2*dim_secu)/2
ENDIF

 

 

Parameter:

 



LOCK "dim_secu"

!VALUES "A" 1+2*dim_secu,2+2*dim_secu
!VALUES "B" 1+2*dim_secu,2+2*dim_secu


IF GLOB_MODPAR_NAME = "A" AND A = 1+2*dim_secu THEN 
PARAMETERS B = 1+2*dim_secu
ENDIF

IF GLOB_MODPAR_NAME = "A" AND A =2+2*dim_secu THEN 
PARAMETERS B = 2+2*dim_secu
ENDIF



IF GLOB_MODPAR_NAME = "B" AND B =1+2*dim_secu THEN 
PARAMETERS A = 1+2*dim_secu
ENDIF

IF GLOB_MODPAR_NAME = "B" AND B = 2+2*dim_secu THEN 
PARAMETERS A = 2+2*dim_secu
ENDIF

 

 

 

 

1 ACCEPTED SOLUTION
6 REPLIES 6
scottjm
Expert

I’m not able to download the objects at the moment  to interrogate in detail, but I think your issue is stemming from the fact you are attempting to change a parameter inside the object from the MVO, which can’t be done. An objects parameter can only be changed via script when the parameter script of that object is run. And that only runs when you change a setting parameter of that object. 

I think you need to restructure your script to just read whether the setting you are applying in the MVO is on or off. And then your 2D script should just draw the safety margin there based on the value being on or off. Not try and modify the parameters. 

Hope that makes sense. 

Scott J. Moore | Fulton Trotter Architects | BIM Manager, Associate, Architect
Since AC13 | Current versions AC23.7000 & AC26.5002 | BIMCloud Basic | Python, GDL, VBA, PHP, SQL, CSS
Certified Graphisoft BIM Manger (2022)
Win 10, i9-9900K, 32GB, Quadro P2200, 500GB NVMe
Mathias Jonathan
Advocate

Thank you for your reply.

 

The parameters can be modified via the model view options: size A & B take the new size into account in real time when modified by MVO.

But indeed, the problem seems to lie with the parameter script:
My conditions (If...then...) to make my script work are based on values that are set using the VALUES function, and the VALUES function only works when the parameter script is executed.

 

I wonder if there's an alternative/strategy in terms of code to avoid using the VALUES function.

I confess I didn't quite understand your recommendation.

scottjm
Expert

You need to decide where you want to change the dim_secu parameter, from the object, or from the MVO.  You can't have it modifiable from both spots.  

If you did want that, you would need to have an option in the object to decide if you want to read from an object specific dim_secu or the MVO dim_secu.

 

If i deleted dim_secu from the object, i was able to modify dim_secu from the MVO and it seems to be working.  Kind of.

 

I think your use of trying to use A & B to dictate whether you are drawing a square of a circle is complicating things.   And then ending that into your if/else statements is causing your issues.

 

Would it not be easier to just use a drop down where you can choose either Circle or Square, then capture what you want your safety margin you need is.  Then in your 2D script your if else statement based on the Circle or Square option, and then simply add the safety margin to the x,y cords of the rect2 or circle2.

 

Also just to clarify, the VALUES function will only change what the available value of the param is, it won't actually change the param to that value.  For that you need to use the PARAMETERS function.

 

 

Scott J. Moore | Fulton Trotter Architects | BIM Manager, Associate, Architect
Since AC13 | Current versions AC23.7000 & AC26.5002 | BIMCloud Basic | Python, GDL, VBA, PHP, SQL, CSS
Certified Graphisoft BIM Manger (2022)
Win 10, i9-9900K, 32GB, Quadro P2200, 500GB NVMe
Solution

Yves, a french user sent me a solution to the problem, using only the master script:

 

succes = LIBRARYGLOBAL ("MVO_EXAMPLE", "dim_secu_glob" , dim_secu)	

a1 = 1+2*dim_secu
a2 = 2+2*dim_secu


IF A < 1.5-EPS THEN
A = a1
B = a1
ELSE
A = a2
B = a2
ENDIF

IF GLOB_MODPAR_NAME = "A"  THEN 
PARAMETERS B = A
ELSE
PARAMETERS A = B
ENDIF

 

 

Peter Baksa
Graphisoft
Graphisoft

Hi, that might work technically, but only as long as the users don't forget that each MVO set should contain the same margin value.

 

Consider you have two objects.

The master script ensures they are both drawn by the current MVO, but the parameters only change when the script is run in parameter script context (settings dialog or hotspot edit), so contain the effect of the MVO at that time. One object might have been changed using one MVO, the other object by another.

Scheduling or labeling their A/B parameters will show different values.

 

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Thanks, you made my day 🙂

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!