BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

GDL
About building parametric objects with GDL.
SOLVED!

Poly2_B{2} Fill Origin & Movement

LGreen
Booster

I've reached a dead-end and can't work this out.  It's a first for me using the POLY2_B{2} command and I'm trying to set the fill origin for a fill to the center of the fill.  I've got the j4(8) code in the frame fill it responds to changes in the origin variables.

 

However, before drawing the fill several cursor movements are made to get to that point.  Now when the fill is drawn the origin is all over the place.  I've included a test object code below (no parameters required) which shows this.  There's a loop that draws the fill, rotates 90° and draws the fill again.  Drawing it 4 times.  The origin is in the center and everything is good. 

 

But then a simple ADD2 1,1 is added before the loop. Now the fill's origins are off by 200mm for each iteration of the loop in one or both the x & y directions.  If I throw in an angle for the fill origin it gets even more confusing.  I had assumed the fill origin x / y coordinates would be based off the cursor position, but that's not the case.  Does anyone know what's going on here?  Or do I need to draw the fills without any movement commands?  Thanks,

 

 

x1 = 0
x2 = 4
y1 = 2
y2 = 4
fill_x = (x2-x1)/2+x1
fill_y = (y2-y1)/2+y1

HOTSPOT2 0,0					!!==== CENTER PRE MOVE				
!ADD2 1,1					!!==== TURN THIS ON / OFF
HOTSPOT2 0,0					!!==== CENTER AFTER MOVE					

FILL 127
FOR i = 1 TO 4

	fillosx = 0		!!=== USED TO TEST EDITING THE ORIGIN 
	fillosy = 0
	rot_angle = 0

!	IF i = 2 THEN		!!=== USED TO TEST EDITING THE ORIGIN FOR EACH LOOP
!		fillosy = -0.200
!		rot_angle = 0
!	ENDIF
!	IF i = 3 THEN
!		fillosx = -0.200
!		fillosy = -0.200
!		rot_angle = 0
!	ENDIF
!	IF i = 4 THEN
!		fillosx = -0.200
!		rot_angle = 0
!	ENDIF

	HOTSPOT2 x1, y1
	HOTSPOT2 x1, y2
	HOTSPOT2 x2, y1
	HOTSPOT2 x2, y2

	HOTSPOT2 fill_x, fill_y		!!=== WHAT SHOULD BE THE FILL'S ORIGIN
	POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
		x1,	y1,	15,
		x2, y1,	15,
		x2,	y2,	15,
		x1,	y2,	15,
		x1,	y1,	15
	ROT2 90
 NEXT i

 

 


Fill Origins - Moved 1-1.JPGFill Origins - No Movement.JPG
Lachlan Green | Architect | Drafter
AusBuild
AC23 & 25 | Windows 10 | Intel 11Gen Core i7 | 2.5GHz | 32GB RAM | Nvidia T1200
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
AllanP
Advocate

Hi,

don't confuse what you think you see with what you should look at.

if you explode the object (Ctrl+=) then you see the origin is off by 1mx1m.(i added in a slight rotation and a larger scaled fill to pick this up)

AllanP_0-1671498602718.pngAllanP_1-1671498608604.pngAllanP_2-1671498615639.png

 

 

because the temp origin is being calculated then

 

ox = 3     !!==== move any amount
oy = 1     !!==== move any amount
x1 = 0
x2 = 4
y1 = 2
y2 = 4
fill_x = (x2-x1)/2+x1
fill_y = (y2-y1)/2+y1
line2 0,0,1,0.25
HOTSPOT2 0,0 !!==== CENTER PRE MOVE
ADD2 ox,oy       !!==== move any amount
HOTSPOT2 0,0 !!==== CENTER AFTER MOVE

FILL fillAttribute_1

FOR i = 1 TO 4
fillosx = -ox +ox !!==== move back to the origin  then move forward in the new direction
fillosy = -oy +oy !!==== move back to the origin  then move forward in the new direction
rot_angle = 11

IF i = 2 THEN !!=== USED TO TEST EDITING THE ORIGIN FOR EACH LOOP
fillosx = -ox+oy   !!==== move back to the origin  then move forward in the new rotated direction
fillosy = -oy -ox  !!==== move back to the origin then move forward in the new rotated direction
ENDIF
IF i = 3 THEN
fillosx = -ox -ox !!==== move back to the origin  then move forward in the new rotated direction
fillosy = -oy -oy !!==== move back to the origin  then move forward in the new rotated direction
ENDIF
IF i = 4 THEN
fillosx = -ox-oy !!==== move back to the origin  then move forward in the new rotated direction
fillosy = -oy+ox !!==== move back to the origin  then move forward in the new rotated direction
ENDIF

HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2

HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 90
NEXT i

AllanP_4-1671500621008.pngAllanP_5-1671500634181.png

I hope this explains the strange behavior .

you could use sin and cos for non 90degree angles

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

i.e.

i_angle = 30

rotangle = 0
FOR i = 1 TO 4
rot_angle = 11
fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)

HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2

HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
rotangle = rotangle +i_angle

NEXT i

 

AllanP_6-1671505177596.png

 

or you can jump to POLY2_B{3} where the problem doesn't exist....

FOR i = 1 TO 4
rot_angle = 11

HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2

HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN

POLY2_B{3} 5, 1+2+4+8, 1, 19, fill_x , fill_y ,!!!!! rot_angle,replaced by next 4 values
1*cos(rot_angle),1*sin(rot_angle),0-1*sin(rot_angle),1*cos(rot_angle),
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
NEXT i

AllanP_8-1671506542656.png

 

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

View solution in original post

3 REPLIES 3
Solution
AllanP
Advocate

Hi,

don't confuse what you think you see with what you should look at.

if you explode the object (Ctrl+=) then you see the origin is off by 1mx1m.(i added in a slight rotation and a larger scaled fill to pick this up)

AllanP_0-1671498602718.pngAllanP_1-1671498608604.pngAllanP_2-1671498615639.png

 

 

because the temp origin is being calculated then

 

ox = 3     !!==== move any amount
oy = 1     !!==== move any amount
x1 = 0
x2 = 4
y1 = 2
y2 = 4
fill_x = (x2-x1)/2+x1
fill_y = (y2-y1)/2+y1
line2 0,0,1,0.25
HOTSPOT2 0,0 !!==== CENTER PRE MOVE
ADD2 ox,oy       !!==== move any amount
HOTSPOT2 0,0 !!==== CENTER AFTER MOVE

FILL fillAttribute_1

FOR i = 1 TO 4
fillosx = -ox +ox !!==== move back to the origin  then move forward in the new direction
fillosy = -oy +oy !!==== move back to the origin  then move forward in the new direction
rot_angle = 11

IF i = 2 THEN !!=== USED TO TEST EDITING THE ORIGIN FOR EACH LOOP
fillosx = -ox+oy   !!==== move back to the origin  then move forward in the new rotated direction
fillosy = -oy -ox  !!==== move back to the origin then move forward in the new rotated direction
ENDIF
IF i = 3 THEN
fillosx = -ox -ox !!==== move back to the origin  then move forward in the new rotated direction
fillosy = -oy -oy !!==== move back to the origin  then move forward in the new rotated direction
ENDIF
IF i = 4 THEN
fillosx = -ox-oy !!==== move back to the origin  then move forward in the new rotated direction
fillosy = -oy+ox !!==== move back to the origin  then move forward in the new rotated direction
ENDIF

HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2

HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 90
NEXT i

AllanP_4-1671500621008.pngAllanP_5-1671500634181.png

I hope this explains the strange behavior .

you could use sin and cos for non 90degree angles

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

i.e.

i_angle = 30

rotangle = 0
FOR i = 1 TO 4
rot_angle = 11
fillosx = -ox +ox*cos(rotangle)+oy*sin(rotangle)
fillosy = -oy +oy*cos(rotangle)-ox*sin(rotangle)

HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2

HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN
POLY2_B{2} 5, 1+2+4+8, 1, 19, fill_x +fillosx, fill_y +fillosy, rot_angle,
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
rotangle = rotangle +i_angle

NEXT i

 

AllanP_6-1671505177596.png

 

or you can jump to POLY2_B{3} where the problem doesn't exist....

FOR i = 1 TO 4
rot_angle = 11

HOTSPOT2 x1, y1
HOTSPOT2 x1, y2
HOTSPOT2 x2, y1
HOTSPOT2 x2, y2

HOTSPOT2 fill_x, fill_y !!=== WHAT SHOULD BE THE FILL'S ORIGIN

POLY2_B{3} 5, 1+2+4+8, 1, 19, fill_x , fill_y ,!!!!! rot_angle,replaced by next 4 values
1*cos(rot_angle),1*sin(rot_angle),0-1*sin(rot_angle),1*cos(rot_angle),
x1, y1, 15,
x2, y1, 15,
x2, y2, 15,
x1, y2, 15,
x1, y1, 15
ROT2 i_angle
NEXT i

AllanP_8-1671506542656.png

 

 

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)

That made me think of Obi-Wan - "Your eyes deceive you. Don't trust them".  Exploding the object to find the actual origin is a nice trick I hadn't thought of.   

 

Attached is an image of the exploded fills from the object I'm working on.  It's one fill command that sits within two loops.  Now that I know where the actual origins are, I'm considering if I should spend the time to work out how to control these fills.  Or just change the script to draw some lines over the top and make it look like the fill I need.

 

Thanks again for the help.


Fill Origins - exploded.JPG
Lachlan Green | Architect | Drafter
AusBuild
AC23 & 25 | Windows 10 | Intel 11Gen Core i7 | 2.5GHz | 32GB RAM | Nvidia T1200

sorry, had school run, last day of term, didn't have time to finish the post.

just go for POLY2_B{3} which uses "Distorted fill" settings rather than "rotation relative to fill origin" setting for POLY2_B{2}.

I have been using ArchiCAD continually since ArchiCAD 4.5, 4.5.5, 5, 5.1, 6, 6.5, 7, 8, 8.1, 9, 10, 11, 12, 13, 15, 18, 21, 22, 25, now testing 27
Member of Architalk since 2003, but missed the migration to Graphisoft.
(where have all my original posts gone?)
Learn and get certified!