cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
GDL
About building parametric objects with GDL.

macro parameters

silvermat
Participant

Hello,

It's my first time, when I try using macros and don't understand it workflow.
I created label as macro and wanted to add it to my host object as several instances

 

label is simple:
generate text with ID and hotspots which determinate localization of label.

 

When I try to call it in host, it generate error "ID_X is not propper parameter name.


 

! Styl czcionki
define style{2} font_style Arial, gs_font_size*5, 1 
style font_style 

! Unikalny paragraf dla ID
ID_paragraph = ID + "_paragraph" 

! Pozycjonowanie tekstu
add2 ID_X, ID_Y
    mul2 1 - 2 * SYMB_MIRRORED, 1
        rot2 -SYMB_ROTANGLE * (SYMB_ROTANGLE <> 0)
        paragraph ID_paragraph 1, 0, 
            0, 0, 1 
            pen font_pen 
            style font_style 
            ID 
        endparagraph
        textblock 'ID_textblock' 0, anchor, 0, 1, 1, 0, 
            ID_paragraph 
        richtext2 0, 0, 'ID_textblock' 
del 3

!----------------------------------------
! Hotspoty do zmiany lokalizacji
!----------------------------------------
hsid = 1
! MACRO LABEL
! Hotspoty w poziomie
hotspot2 0, ID_Y, hsid, ID_X, 1 + 128, ID_X: hsid = hsid + 1
hotspot2 ID_X, ID_Y, hsid, ID_X, 2, ID_X: hsid = hsid + 1
hotspot2 -1, ID_Y, hsid, ID_X, 3, ID_X: hsid = hsid + 1

! Hotspoty w pionie
hotspot2 ID_X, 0, hsid, ID_Y, 1 + 128, ID_Y: hsid = hsid + 1
hotspot2 ID_X, ID_Y, hsid, ID_Y, 2, ID_Y: hsid = hsid + 1
hotspot2 ID_X, -1, hsid, ID_Y, 3, ID_Y: hsid = hsid + 1

 

parameters in editor:
ID, ID_X, ID_Y, gs_font_size, font_pen, anchor, font_style

 

!Host code
!...
call "JA_Etykieta_ID" parameters all,
				ID_X = ID_X_chair,
				ID_Y = ID_Y_chair,
				ID = _chair_ID,
				anchor = 5
!... rest of code

 

in parameters i have ID_X_chair, ID_Y_chair, _chair_ID and others

Why it is not working? 😞

8 REPLIES 8
Jochen Suehlo
Moderator

You should have the same Parameters in the caller as in the macro. E.g. if you add ID_X and ID_Y as Parameters in the caller, the you will not have this error message, even if you do not use this parameters.

Jochen Suehlo . AC12-28 . MAC OSX 14.4 . WIN11
GDL object creation: b-prisma.de

 

I want to use that label multiple times in some objects, E.g. in sink object I add mirror, bin, soap etc.
Every item has their own ID label with own coords. I don't want create in macro 5 times parameters with coords named "ID_X_mirror", "ID_X_soap" etc.
because I use that label in desk object where I dont have mirror, soap and so on but chair, box, pc etc.

second fact is that when I create different hotspots in label with different coords, then it all move same label even if I place it in different location when I move label 1 it move label 2 with one hotspot.

silvermat_1-1758176704900.png silvermat_2-1758177355828.png

 

 

 

 

It would only need to be ID_X and ID_Y that would be added to the host object, that is overrided with the desired value when you call the macro.

 

Ling.

AC22-28 AUS 3110Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win11 | R5 2600 | 16GB | GTX1660

But how can I call my label 2 times in one object when location of it should be different and hotspots should be dynamic?

When I write:
call "JA_Etykieta_ID", parameters all, ID = ID_desk ID_X = ID_X, ID_Y = ID_Y it create hotspot in ID_X, ID_Y

And when I try to call it again if I call it with the same parameters, it apears in the same place

call "JA_Etykieta_ID", parameters all, ID = ID_chair, ID_X = ID_X, ID_Y = ID_Y it create hotspot in ID_X, ID_Y

I can't move just one of them.

Every time you call the macro, you have to pass on different parameter values to the same parameter.

 

So for the mirror you would call with the parameters ID_X = ID_X_mirror, ID_Y = ID_Y_mirror

And for the sop dish ID_X = ID_X_soap, ID_Y = ID_Y_soap

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

I did that, but that doesn't work properly.
When I try to move second label with it hotspot, it move first label instead.

Actually I've change textblock to print hsid instead of ID so I can see if there is any collision.

 

silvermat_3-1758534716499.png

 

 

Here is my code and params. Hope you can find any mistakes.

 

Parent code:

! -------------------------------------------------------------------------------------------------
! Variables
_bSuccess = LIBRARYGLOBAL("ZZZ_Janowicz Architekci - ORM", "JA_show_eq", _eq_MVO)
_bSuccess = LIBRARYGLOBAL("ZZZ_Janowicz Architekci - ORM", "JA_show_id", _id_MVO)

! -------------------------------------------------------------------------------------------------

! define style{2} "JA_font_style_1" Arial, gs_font_size*5, 1
! style 'JA_font_style_1'
pen gs_cont_pen
fill gs_fill_type


gosub "draw box"
rot2 -30
add2 A/6,	B/4
gosub "energy"
del 2
gosub "description"

gosub "hotspots"

! ==================================================================================================
end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end ! end
! ==================================================================================================
! ==================================================================================================
"draw box":
! ==================================================================================================

	poly2_b 4,	7,
		gs_fill_pen, gs_back_pen,
		0,	0,	1,
		0,	B,	1,
		A,	B,	1,
		A,	0,	1

	line2	0,	0,	A,	B
	line2	A,	0,	0,	B

	
return
! ==================================================================================================
"energy":
! ==================================================================================================
	poly2 4,	1,
		0,	0,
		0,	B*3/5,
		0.05,	B*3/5 - 0.05,
		0.05,	B-0.05

	poly2_b 3,	7,
		gs_cont_pen, gs_cont_pen,
		0,	0,	1,
		-0.025,	0.1,	1,
		0.025,	0.1,	1
	
return
! ==================================================================================================
"description":
! ==================================================================================================
	hsid = 20
	call "JA_Etykieta_ID" parameters all,
		ID = GLOB_ID,
		hsid = hsid + 7,
		returned_parameters hsid

	call "JA_Etykieta_ID", parameters all, 
		ID = "soap", 
		ID_X = ID_X_soap, 
		ID_Y = ID_Y_soap, 
		hsid = hsid + 7, 
		returned_parameters hsid
	call 'Z_C_K' parameters all
return

! ==================================================================================================
"hotspots":
! ==================================================================================================
	hotspot2 0,	0,	hsid : hsid = hsid + 1
	hotspot2 A,	0,	hsid : hsid = hsid + 1
	hotspot2 A,	B,	hsid : hsid = hsid + 1
	hotspot2 0,	B,	hsid : hsid = hsid + 1
	

	
return

silvermat_0-1758534614700.png

 

Label code:

! Styl czcionki
define style{2} font_style Arial, gs_font_size*5, 1 
style font_style 

! Unikalny paragraf dla ID
ID_paragraph = ID + "_paragraph" 

! Pozycjonowanie tekstu
add2 ID_X, ID_Y
    mul2 1 - 2 * SYMB_MIRRORED, 1
        rot2 -SYMB_ROTANGLE * (SYMB_ROTANGLE <> 0)
        paragraph ID_paragraph 1, 0, 
            0, 0, 1 
            pen font_pen 
            style font_style 
            ! ID 
			str(hsid, 2	,	0)
        endparagraph
        textblock 'ID_textblock' 0, anchor, 0, 1, 1, 0, 
            ID_paragraph 
        richtext2 0, 0, 'ID_textblock' 
del 3

!----------------------------------------
! Hotspoty do zmiany lokalizacji
!----------------------------------------
! hsid = 1

! Hotspoty w poziomie
	h_local = hsid
	nHot = 0

	hotspot2 0,     ID_Y,  h_local+nHot, ID_X, 1+128, ID_X : nHot = nHot + 1
	hotspot2 ID_X,  ID_Y,  h_local+nHot, ID_X, 2,     ID_X : nHot = nHot + 1
	hotspot2 -1,    ID_Y,  h_local+nHot, ID_X, 3,     ID_X : nHot = nHot + 1

	hotspot2 ID_X, 0,      h_local+nHot, ID_Y, 1+128, ID_Y : nHot = nHot + 1
	hotspot2 ID_X, ID_Y,   h_local+nHot, ID_Y, 2,     ID_Y : nHot = nHot + 1
	hotspot2 ID_X, -1,     h_local+nHot, ID_Y, 3,     ID_Y : nHot = nHot + 1
	hsid = h_local + nHot
end hsid

 

silvermat_1-1758534628142.png

 

silvermat
Participant

Is there anyone who can help me?

easyDoesIt
Booster

 

It wasn't clear if you have assigned different hotspots for each label. And don't think you can define the hostpots in the child, need to be in parent, you could make it an array in the parent to be tidy. ID_X[][3], ID_Y[][3]

 

The macro call places the child object using the parameters (or values) assigned to it. If you want to call the same macro twice and act independently they need to use different parameters in the parent object.

 

So in your parent object you need different X and Y parameters for each label. Then when you call the label you assign the parent hotspot to the child. So...

 

!!!!!!!!!!!!!!!!Parent (object)
! parameters
! ID_X_soap
! ID_Y_soap
! ID_X_Shampoo
! ID_Y_Shampoo

nHot = 1

hotspot2 0,     ID_Y_soap,  nHot, ID_X_soap, 1+128, ID_X_soap : nHot = nHot + 1
hotspot2 ID_X_soap,  ID_Y_soap,  nHot, ID_X_soap, 2,     ID_X_soap : nHot = nHot + 1
hotspot2 -1,    ID_Y_soap,  nHot, ID_X_soap, 3,     ID_X_soap : nHot = nHot + 1

hotspot2 ID_X_soap, 0,      nHot, ID_Y_soap, 1+128, ID_Y_soap : nHot = nHot + 1
hotspot2 ID_X_soap, ID_Y_soap,   nHot, ID_Y_soap, 2,     ID_Y_soap : nHot = nHot + 1
hotspot2 ID_X_soap, -1,     nHot, ID_Y_soap, 3,     ID_Y_soap : nHot = nHot + 1

call "JA_Etykieta_ID", 
  ID = "soap", 
  ID_X = ID_X_soap, 
  ID_Y = ID_Y_soap, 
  hsid = hsid + 7, 
  returned_parameters hsid

hotspot2 0,     ID_Y_Shampoo,  nHot, ID_X_Shampoo, 1+128, ID_X_Shampoo : nHot = nHot + 1
hotspot2 ID_X_Shampoo,  ID_Y_soap,  nHot, ID_X_Shampoo, 2,     ID_X_Shampoo : nHot = nHot + 1
hotspot2 -1,    ID_Y_Shampoo,  nHot, ID_X_Shampoo, 3,     ID_X_Shampoo : nHot = nHot + 1

hotspot2 ID_X_Shampoo, 0,      nHot, ID_Y_Shampoo, 1+128, ID_Y_Shampoo : nHot = nHot + 1
hotspot2 ID_X_Shampoo, ID_Y_Shampoo,   nHot, ID_Y_Shampoo, 2,     ID_Y : nHot = nHot + 1
hotspot2 ID_X_Shampoo, -1,     nHot, ID_Y_Shampoo, 3,     ID_Y_Shampoo : nHot = nHot + 1

call "JA_Etykieta_ID", 
  ID = "shampoo", 
  ID_X = ID_X_shampoo, 
  ID_Y = ID_Y_shampoo, 
  hsid = hsid + 7, 
  returned_parameters hsid

!!!!!!!!!!!!!!!Child object (label)
! parameters
! ID
! ID_X
! ID_Y
! hsid

......

richtext2 ID_X, ID_Y, 'ID_textblock' 

 

Cheers, Mark
archibites.tech | Wet Area Tool | Door Circulation Compliance | Multi-Label | Roof Slope | Wall Type Label
Brisbane, Australia