Home › Forums › Problems and solutions in GDL › Object design › Centerpoint in simpel 2D symbol
Tagged: center, anchorpoint
- This topic has 8 replies, 3 voices, and was last updated 7 years, 7 months ago by David Maudlin.
-
AuthorPosts
-
-
February 27, 2017 at 09:36 #2977Anders JuulParticipant
Hi
I have a simple rectangle, whits is set up to scale automatic after Pepersize.
I would like that the symbol to scale from the center, and not from the corner.
How do I do that?Here is my very simple GDL script and also se attached
Best regards Anders / Denmark
__paperToModel = GLOB_SCALE / 1000
bb = bb_mm * _paperToModelmul2 a, b
add2 5, 5
pen penAttribute_1line2 0*bb,0*bb,0*bb,3*bb
line2 0*bb,3*bb,10*bb,3*bb
line2 10*bb,3*bb,10*bb,0*bb
line2 10*bb,0*bb,0*bb,0*bb_
Attachments:
-
February 27, 2017 at 14:00 #2979David MaudlinParticipant
Anders:
You will need to rewrite the code so the center of the rectangle is at the 0, 0 point. So the lower left will be two negative numbers (-5*bb, -1.5*bb), the upper right two positive numbers (5*bb, 1.5*bb). I think this is simpler than trying to use the Add2 command to adjust the center.
David
David Maudlin / Architect
Washington, D.C.
AC 22 - Mac OS -
February 28, 2017 at 09:27 #2980Anders JuulParticipant
Thanks David
But if the symbol is more complex like attached. Do i have to rewrite the code to?
I created this symbol by select the drawings, and use “save selection as object”___
_paperToModel = GLOB_SCALE / 1000
_size1_model = Str_mm * size1_mm * _paperToModel
_size2_model = Str_mm * size2_mm * _paperToModelmul2 _size1_model , _size2_model
add2 -6.838723289463, -2.084918350452
pen penAttribute_1
fill fillAttribute_1
poly2_b{5} 15, 2, 0, 3, penAttribute_1, penAttribute_2,
0, 0, 1, 0, 0, 1, 0,
6.838723289463, 2.484918350452, 1,
6.838723289463, 2.084918350452, 1,
7.238723289463, 2.084918350452, 1,
7.238723289463, 2.284918350453, 1,
7.063723289463, 2.109918350452, 1,
6.938723289463, 2.109918350452, 1,
7.063723289463, 2.234918350452, 1,
6.863723289463, 2.234918350452, 1,
6.863723289463, 2.334918350452, 1,
7.063723289463, 2.334918350452, 1,
6.938723289463, 2.459918350452, 1,
7.063723289463, 2.459918350452, 1,
7.238723289463, 2.284918350453, 1,
7.238723289463, 2.484918350452, 1,
6.838723289463, 2.484918350452, 1
pen penAttribute_3
fill fillAttribute_1
poly2_b{5} 10, 2, 0, 3, penAttribute_3, penAttribute_3,
0, 0, 1, 0, 0, 1, 0,
7.063723289463, 2.334918350452, 1,
6.863723289463, 2.334918350452, 1,
6.863723289463, 2.234918350452, 1,
7.063723289463, 2.234918350452, 1,
6.938723289463, 2.109918350452, 1,
7.063723289463, 2.109918350452, 1,
7.238723289463, 2.284918350453, 1,
7.063723289463, 2.459918350452, 1,
6.938723289463, 2.459918350452, 1,
7.063723289463, 2.334918350452, 1
_____Attachments:
-
February 28, 2017 at 14:13 #2982David MaudlinParticipant
Anders:
You could solve this with the Add2 command (there is an Add2 command at line 5 of your script). The values (x, y) will need to be parametric depending on the desired size and the Mul2 values. It will take a bit of thinking and math to get the desired result. Going from a single drawn object to a parametric one is not simple, so this is why I prefer to code it.
David
David Maudlin / Architect
Washington, D.C.
AC 22 - Mac OS -
February 28, 2017 at 14:40 #2983Péter BaksaKeymaster
For all GDL objects, you can select which hotspot acts as origin for scaling. You can do it in the settings dialog preview pane. Simply add a hotspot in the place that you want to use as origo.
If you need the default behaviour of your object being to scale from the origo, you have to do the transformations in the code, after mul2 move it half the new size to downwards and left.
Another way to do it: before Save As, move the drawings center to the project origin, it will be saved relative to that position.
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
March 2, 2017 at 13:03 #2991Anders JuulParticipant
Thanks for your reply. I programed the symbol, and now the symbol scale from the center when I change the paper size 🙂
One more question. How do I make al fill, so the symbol gets a colour : Se se attached
/ Anders
_paperToModel = GLOB_SCALE / 1000
bb = bb_mm * _paperToModelmul2 a, b
add2 0, 0
pen penAttribute_1
line_property 0! Firkant line
line2 -500*bb,-500*bb,-500*bb,500*bb
line2 -500*bb,500*bb,500*bb,500*bb
line2 500*bb,500*bb,500*bb,-500*bb
line2 500*bb,-500*bb,-500*bb,-500*bb
! pil line
line2 -500*bb,0*bb,-50*bb,400*bb
line2 -50*bb,400*bb,300*bb,400*bb
line2 300*bb,400*bb,50*bb,150*bb
line2 50*bb,150*bb, 400*bb,150*bb
line2 400*bb,150*bb, 400*bb,-150*bb
line2 400*bb,-150*bb, 50*bb,-150*bb
line2 50*bb,-150*bb, 300*bb,-400*bb
line2 300*bb,-400*bb, -50*bb,-400*bb
line2 -50*bb,-400*bb, -500*bb,0*bbAttachments:
-
March 2, 2017 at 14:05 #2993David MaudlinParticipant
Anders:
Since you have now defined all the points using the Line2 command, you can use these same points with one of the Poly2_ commands (which one you choose depends on the amount of control you want over the fill). The Poly2_ command can draw both the fill and its outline (look at the frame_fill options) so you will be able to remove the Line2 commands when done.
David
David Maudlin / Architect
Washington, D.C.
AC 22 - Mac OS -
March 2, 2017 at 15:46 #2994Anders JuulParticipant
Hi David
Can you give my an examble? My GDL skills is not the best 🙂
-
March 2, 2017 at 22:42 #2996David MaudlinParticipant
Anders:
In the US library is an Object “Sign Handicap 20” which uses the Poly2_{2} command to draw the handicap symbol. It has hard coded x & y points rather than parametric ones like yours, but otherwise the concept is the same. See if you have this object or can search for it or a similar one to look at. Some information about General polygon can be found on this site 05 Basic 2D elements. Maybe the moderators can point to better examples.
David
David Maudlin / Architect
Washington, D.C.
AC 22 - Mac OS
-
-
AuthorPosts
- The forum ‘Object design’ is closed to new topics and replies.