Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamic Polyline base code object

sinceV6
Beginner
Hello everyone.

In the past couple of months I've been in a GDL streak creating, updating and fixing lots of little self made parts... and the code just seemed to flow; so I tackled my wish to have (make, to learn, in my case) a dynamic polyline. A few months ago, I sketched a new "parking place" object that I wanted, but just didn't have the time to do; and didn't really need because I've just been adding stuff and parameters to the GS parking place object for years.

I did some research a few years ago, but just kept the links for reference. Now that I was naturally digging into GDL again, I though I could make it possible.

The basic code for a Dynamic Polyline is useful for me; and I thought many people here could benefit from it. I tried several approaches for two weeks trying to make it work the way I wanted (I'm really no expert in GDL). It solves a few issues and serves as learning resource too, as it dynamically adds points to the polyline between segments, adds points at the end, dynamically removes points and dynamically grows and shrinks arrays.

I already have other ideas for this, like a 3D railing (the code already has Z for each point). I'm not putting it in BIMcomponents (this is for AC15+) or the Depository as it is not a final product.

I hope you find it useful, if you do, leave a comment; the only condition is that if you use it for something, you must post back the developed object with the code unlocked so other people can see how to implement it in new objects. (so please, no locked commercial derivatives... this is for the community)

Thanks to the plethora of information found in this community.

http://archicad-talk.graphisoft.com/viewtopic.php?p=164099&highlight=polyline#164099
http://archicad-talk.graphisoft.com/viewtopic.php?p=167325&highlight=dynamic+array#167325
http://archicad-talk.graphisoft.com/viewtopic.php?p=163424&highlight=dynamic+array#163424
http://archicad-talk.graphisoft.com/viewtopic.php?p=117388&sid=84c8152f200b0e00fce3c5ca31cce51e
http://archicad-talk.graphisoft.com/viewtopic.php?t=30992&postdays=0&postorder=asc&&start=30&sid=5b2...

Enjoy.

The "Dynamic Polyline ER" base code object:

EDIT: new version: added a few things, like length of the segments, and a visual constraint for the first segment to keep at least 2 points.
37 REPLIES 37

alemanda
Newcomer
Thank you very much for sharing!
At that time (I had time) I studied this problem to write an object for claddings. So I needed a closed dynamic polygone to be used to define a slab to be oriented anyhow in the space ...
I see that your dynamic polyline cannot be closed. Right?
AC 19 and AC21 latest hotfix
Win 10 Pro 64bit
Double XEON 14 CORES (tot 28 physical cores)
32GB RAM - SSD 256GB - Nvidia Quadro K620
Display DELL 25'' 2560x1440
www.almadw.it

Hmooslechner
Advocate
to alemanda:

Its german but its what You need i think..

http://www.youtube.com/watch?v=d1gVAqX6vhc&feature=youtu.be

And on the Bim-portal You can Download the Part (2 Parts) by searching for:

Fliesenteilungen12_2012 a1

and

Fliesenteilungen12_2012 b1

the difference is - You can usw on for the bottoms - one for the walls
AC5.5-AC25EduAut, PC-Win10, MacbookAirM1

sinceV6
Beginner
That base code is to be used with an open polyline/path. You can "close" it in the sense that you can drag the last point to the object's origin, but it won't stay closed.

But, the code is simple enough that with only a few modifications, it can do what you want.

Here it is, modified for you.
I included the area calculation based on:
http://www.wikihow.com/Calculate-the-Area-of-a-Polygon

The script won't check for overlapping segments... so it will give you the area based on clockwise or counterclockwise coordinates (so, some area polygons will have positive area, others negative area). It is the same result if you use the measure tool and trace over all the segments (following their order) including the overlapping segments.

The 3D script will do nothing more than lift the points.

You can extend it to show whatever you need. If you do, share what you accomplish!

Best regards.

Pertti P__sky
Newcomer
Hi sinceV6. Nice job. Is it possible to move the first point too? Makes it more useful.
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

sinceV6
Beginner
Pertti wrote:
Hi sinceV6. Nice job. Is it possible to move the first point too? Makes it more useful.
Hi.

Sure thing. There's already an option for that. Just turn on the "make first hotspot movable" option.

Best regards.

Pertti P__sky
Newcomer
OK, I got it. thanks.
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

Hmooslechner
Advocate
Now i had time to look at Your code.. and i am sure not to understand the half of it.- Wow!

I wish this would have existed when i made my own little steps in this topic. This seems to be exact the "base" for what i was looking for to make a functioning 3D-Railing, a much easier GDL für sewer than i tried to make and so on..


I have to learn much! thats sure.

I will try to adapt this für my existing sewer-Part.

archicad-talk.graphisoft.com/viewtopic.php?t=42112&start=10
AC5.5-AC25EduAut, PC-Win10, MacbookAirM1

Hmooslechner
Advocate
Hi out there!

I took Your polygon-code and programmd my sewer object complete new:

https://www.dropbox.com/s/eme47bhjzfwj13d/Kanal_K.pln

Its in german till now but i'll try to translate it later.

I cheated with the growing polygone - and made it for just 50 Points, that should do it anyway, but Your functionality is still working.

Enjoy and feel free..

Greetings from Austria - Salzburg
AC5.5-AC25EduAut, PC-Win10, MacbookAirM1

sinceV6
Beginner
Hey! That's great work right there!
I'm glad you found it useful. I would like to see the finished object though... and translated. My german is practically non-existent.

Is it finished? I see numbers change when adding or removing points, and I assume they should remain constant.

Let us now when you finish! Would like to see the complete code.

Best regards.

Hmooslechner
Advocate
Its still buggy now and i have to make some restrictions in some parameters too. The numbers should change - thats a feature, the number of a point should be left out if there is no double-circle..

It will take som days to get it to work probberly an then there will be an english version.
AC5.5-AC25EduAut, PC-Win10, MacbookAirM1

Hmooslechner
Advocate
https://www.dropbox.com/s/bjqpf7oqkfzspvp/Kanal_M.pln

This Edu-pln contains an english and the german version - so far as my english knowledge can make it possible.

i also ried to translate parts of the 2D-script - which is the complexer part..

When there is time, ill make an english tutorial for it.
Now You have to look at the german Youtube, but You can see the spirit..

www.youtube.com/watch?v=vfEBqExcyvY
AC5.5-AC25EduAut, PC-Win10, MacbookAirM1

Hmooslechner
Advocate
Just another project with Your polygone-script..

I made this things with my try in this topic and put my code to Your polygon-code.. its sometimes a little buggy but now its possibel to draw "walls" with different bottomhights..

www.youtube.com/watch?v=-FFodVedw4U&feature=youtu.be

its in uplad for a few minutes..


To have a look at the code: /AC16EduAut.pln..)
https://www.dropbox.com/s/wcvwjz0owsbd4aj/Polygonzug_Wand.pln
AC5.5-AC25EduAut, PC-Win10, MacbookAirM1

Olivier Dentan
Newcomer
sinceV6,

Congrats for your Dynamic PolyLine. Thanks for sharing.
I like the cross sign at the end for adding a new segment.

I notice an unexpected behavior with Z coords when removing points. See attached image.
Is it intended to work this way?

Best regards,

sinceV6
Beginner
Hi Olivier.
It's a real honor to hear from you. Each of your objects is a masterpiece! I've learned a few tricks from them. Thank you for sharing all that work.

I'm aware of the issue. In its current version, for removing points, the script iterates from the first to the last point checking the next segment´s length, and always removes the next segment from the edited point regardless of where it is dropped (previous point or next one). This works OK for X and Y coordinates, but for Z does not, as you point out.

I was trying several approaches to solve that, but I had to move to other things, so I added the Z to that block in the script. It has that small caveat for now: in your example, moving point #4 will remove segment from #4 to #5, thus giving its Z value to point #5 even if you move it to the previous point.

The block in the Master script that controls this is
"!=== FOR REMOVING POINTS====
the bunch of code
========================"

I have a few unsuccessful options lying around. I tried to find a way within that block and the already set up parameters so that only that part would need to be changed (copied/pasted to other objects based on this), but I remember I found it might need a couple more of placeholder parameters just to move Z coordinates around, depending on the point being edited.

Before I paused its development, I realized I'd like to rewrite the parts that control adding and removing points and try to make them simpler. Those two blocks in the master script are the ones that control the basic functionality.

I'm afraid to say that I currently lack time to fully revise it. I'm open to ideas/solutions though. When I find some time, I will revise the Z coordinate or rewrite entirely those blocks; in the meantime, if you like to contribute to the code, it would be great. I think the code is clear and commented, each code block has a title indicating what it does, and variables' names are self-explanatory.

Best regards.

Olivier Dentan
Newcomer
sinceV6 wrote:
if you like to contribute to the code, it would be great. I think the code is clear and commented, each code block has a title indicating what it does, and variables' names are self-explanatory.
Fully agree. Your code is clear and well commented. A pleasure.

I was trying your code on a tube object, when I realized this particular problem. Not a major issue.
I asked you because I did not find a quick solution . I will try again.

Attached two objects, in case somebody has an idea.

The first one uses Petri Leeskinen's code (free form window) for dynamic polyline.
Fine, but a bit complicated. Coords numbering is a mess.
Cons, you need to break the last segment to add a new one at the end.

The second object uses your dynamic polyline code, with minor changes.
Once this Z coord problem solved, it will be perfect for me.

Not sure if it works correctly with imperials, sorry.

Best regards,

sinceV6
Beginner
WOW Olivier. Sweet work as usual! I can see where you are going with those objects. How do you code that fast?!?

I also couldn't find a quick solution for the Z coord, at least not one that could be implemented and confined within that block and only with the available parameters.

I can see that Petri's code works as expected, albeit a tad complex, and I noticed the coords numbering problem. I thought modifying it to add a last hotspot (to add points, instead of breaking the last segment) would solve your issues, but I guess the numbering problem wouldn't be addressed and a good part would need to be rewritten or reorganized for this. Didn't take the full plunge into the code, but I can see that my approach is more direct (to adding and removing points) and Petri's is more indirect - by first checking what point or coords are moved/edited and then taking action accordingly. I think the two approaches would need to be combined to solve all issues.

As soon as I find time, I will review Petri's code to see how it works and try to solve (or rewrite) my code and publish a step by step on what to change if objects have been developed using this; but not being as proficient in GDL as you I'm afraid you'll beat me to the answer

Attached are some of the options I kept when looking for a solution. The part being tested -for removing points in master script- is not well formatted (I try to give code a good format so I can return to it later and pick it up as fast as possible), but I guess you won't have major issues with that.

They DON'T WORK entirely (to test them you would need to comment out some of the calculations), but might give you an idea on the approaches I took. Hell... the solution might be there and I made a mistake or just didn't see it.

I'm still amazed at how you write GDL.

Best regards.

Hmooslechner
Advocate
@ SinceV6: Just to inform You as You intendet:

I used the Your code to create a simple numbering (Text) - Object.

Its meant to number things in the plan "at the wild" - now just 2D.

Till i'l have time and its finnishd - its in german but the functionality should be clear

www.youtube.com/watch?v=4TuoHhQlAFE

until it is open on Bim:


https://www.dropbox.com/s/49440b1fb19r6n2/Nummerierungen%20Poly.pln



@ Olivier Dentan:

What would be a real challange: You made this very far developed object for "Garde Corps". Its full functionality applied to the new polygone-Code with Z-coords - that would be "it"!

What i tried to do so far was to calculate an offset to one side, so to make it possible to follow slabs or other contours and mount it on a Sideface - like its done here by us in Austria. But my my spirit is too weak..
AC5.5-AC25EduAut, PC-Win10, MacbookAirM1

mariosmic
Newcomer
Here my contribution.
I created with my own code this editable polyline in 2d/3d with arcs.
Let me know if you have questions.

The use of the code is free.
Mac Pro 3 GHZ 16 GB - OS X 10.12 - Archicad 20
www.studioarcrea.com
www.facebook.com/3DMD.3DMediaDesign

mariosmic
Newcomer
Here a 3d view
Mac Pro 3 GHZ 16 GB - OS X 10.12 - Archicad 20
www.studioarcrea.com
www.facebook.com/3DMD.3DMediaDesign

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!