GDL
About building parametric objects with GDL.

Complex poly object

JGoode
Advocate

Hello,

 

I am trying to create an object which is essentially a 4 sided shape where the 4 corners can be moved which is simple enough on it's own. However there is also the requirement to have the option of adding a fillet or chamfer to each corner. Is this achievable without creating a different poly for every possibility? 

 

Thanks

ArchiCAD 23

Windows 10
20 REPLIES 20
Barry Kelly
Moderator

A simple rectangle would be no problems at all.

I would use PUT statements for the nodes.

And then a POLY with GET to retrieve those nodes.

If you have not seen that done let me know and I will find or make a script for it.

 

So you would have IF statements for the nodes.

If simple corner PUT node coordinates and mask value .

If chamfer PUT 2 node coordinates and mask values.

If fillet PUT node coordinate and mask value, PUT centre coordinate and mask value (900), PUT end of arc coordinate and mask value.

Then GET all of these in the POLY command.

 

If your POLY can have the four corners move independently of each other (i.e. the for sides are not equal in length), then it will be more tricky.

It can still be done as above by using the PUTs in IF statements, but the tricky part will be working out the coordinates of the nodes and the centres of the arcs.

I am sure it is mathematically possible - would just involve a little trigonometry.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Hi Barry,

 

Firstly, thank you for your response. I haven't used PUT statements before so that would be my main issue in even beginning this method. The object could have 4 uneven sides and the corners could be moved to any position so it's as tricky as it gets. 

 

Many thanks

ArchiCAD 23

Windows 10

OK, it is quite late for me now (11pm) and my best thinking for the day is done.

I will try to get a little example together tomorrow after work to show the PUT/GET with a simple rectangle with/without fillets.

 

The un-even shape I will have to think about.

But as I say, it is just trig.

 

BarryKelly_0-1652281162706.png

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

here is a quick put example

 

put 3", 1.75", 15,
3", 1.25", 15,
-3", 1.25", 15,
-3", 1.75", 15

 

poly2_B{2} nsp/3,7+8+16,RangeFillPen,RangeFillBackPen,0,0,SYMB_ROTANGLE,
get(nsp)

 

also the tube object in my sig has a lot of what you need, although its looped so it can have many more than 4 sides. its probably more than you need but maybe it can help.

 

adding fillet or chamfer would be fairly simple to add to the profile.

Barry Kelly
Moderator

OK, here is my quick attempt at a 4 sided polygon that can have plain, chamfered or filleted corners.

I have only done a rectangular polygon based on the A & B sizes (width & height), and I have used PUT and GET to allow for the various nodes required for the different corner types.

 

First you need these parameters.

 

BarryKelly_1-1652363652129.png

 

Then in the Parameter script ...

 

 

VALUES "corner_1" "None", "Chamfer", "Fillet"
VALUES "corner_2" "None", "Chamfer", "Fillet"
VALUES "corner_3" "None", "Chamfer", "Fillet"
VALUES "corner_4" "None", "Chamfer", "Fillet"

 

 

And in the 2D script ...

 

 

if corner_1 = "None" then
	put 0, 0, 1
endif
if corner_1 = "Chamfer" then
	put 0, 0+fillet_rad_1, 1
	put 0+fillet_rad_1, 0, 1
endif
if corner_1 = "Fillet" then
	put 0, 0+fillet_rad_1, 1
	put 0+fillet_rad_1, 0+fillet_rad_1, 900
	put 0+fillet_rad_1, 0, 3001
endif

if corner_2 = "None" then
	put A, 0, 1
endif
if corner_2 = "Chamfer" then
	put A-fillet_rad_2, 0, 1
	put A, 0+fillet_rad_2, 1
endif
if corner_2 = "Fillet" then
	put A-fillet_rad_2, 0, 1
	put A-fillet_rad_2, 0+fillet_rad_2, 900
	put A, 0+fillet_rad_2, 3001
endif

if corner_3 = "None" then
	put A, B, 1
endif
if corner_3 = "Chamfer" then
	put A, B-fillet_rad_3, 1
	put A-fillet_rad_3, B, 1
endif
if corner_3 = "Fillet" then
	put A, B-fillet_rad_3, 1
	put A-fillet_rad_3, B-fillet_rad_3, 900
	put A-fillet_rad_3, B, 3001
endif

if corner_4 = "None" then
	put 0, B, 1
endif
if corner_4 = "Chamfer" then
	put 0+fillet_rad_4, B, 1
	put 0, B-fillet_rad_4, 1
endif
if corner_4 = "Fillet" then
	put 0+fillet_rad_4, B, 1
	put 0+fillet_rad_4, B-fillet_rad_4, 900
	put 0, B-fillet_rad_4, 3001
endif

 
PEN fill_perim_pen
FILL fill_style

poly2_B nsp/3,1*1 + 2*1 + 4*1 + 8*0 + 32*0 + 64*0,fill_foreground_pen,fill_background_pen,
get(nsp)

 

 

That will give you a rectangular polygon that stretches by the corner hotspots.

And the corners can be set to either none,chamfer or fillet.

 

BarryKelly_3-1652364195082.png

 

 

To have truly stretchy corner nodes (can be stretched in any direction) is quite easy.

You just need parameters for the x & y coordinates of the corners and if you want add stretchy hotspots for them.

The trick then is doing the calculations to work out where the coordinates are for the extra nodes needed for the chamfer and fillets.

Someone smarter than me will have to work that one out.

For each corner you will need to take into consideration the position of the two adjacent corners, as that will affect the edge line angles which will affect where the extra nodes are for the chamfer and fillet corners.

 

But this is a good example of how the PUT/GET part works.

 

Barry.

 

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Hi Barry, 

 

This is much further than I would have got on my own! Thank you very much. I'm having a bit of an issue with the fillet on corner 1. I had issues with the chamfer on corner 1 which I resolved but the lines are not connecting correctly after the curve. The line which should go from corner 1 to corner 2... goes to corner 4 and visa versa. 

 

Any ideas why or how to fix?

 

Edit: Problem solved, had to figure it out and shuffle some values around. Thanks again for your time and help!

ArchiCAD 23

Windows 10

Sorry, it looks like I missed copying the script for the first corner.

I will fix that up.

 

You have to be very methodical and make sure all your nodes are in the correct order.

That is why I often use PUT for every node.

So I can simply reorder then by dragging the script lines around.

 

When you have multiple PUTS, you can group them together with one PUT statement and a comma after at the end (so it is basically a continuation to the next line), and no comma at the very end of the last line.

 

So ...

put 0, 0+fillet_rad_1, 1
put 0+fillet_rad_1, 0+fillet_rad_1, 900
put 0+fillet_rad_1, 0, 3001

could also be written ..

put 0, 0+fillet_rad_1, 1,
0+fillet_rad_1, 0+fillet_rad_1, 900,
0+fillet_rad_1, 0, 3001

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
A_ Smith
Expert

I believe I make it with editable corners, even if shape isn't a rectangular (Archicad 22)

https://drive.google.com/file/d/1sqWMpqrC2YryQ5cZ68y1e-u_akk6yLLA/view?usp=drivesdk

AC 22, 24 | Win 10

@A_ Smith ,

Yes, that looks great.

You have the chamfer (straight cut) and fillet (curved) mixed up though.

 

The stretchy hotspots for the corner radius seem a little weird to use, but that is because they are measuring from the centre point. It is just weird that the radius doesn't match the actual hotspot as you drag it. But I don't think there is much you can do differently.

Just takes a little getting used to.

 

To make it even better, maybe hide the hotspot when it is a straight corner.

Then you wouldn't need the option to show/hide the radius hotspot (although of course you can keep that option).

 

I was also going to suggest you could add a 'switch' hotspot to change the corner type as well.

But I see you have allowed that and can turn that option on/off.

 

Great job.

Thanks for sorting out the geometry.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

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!