GDL
About building parametric objects with GDL.

Novice GDL question - which 3D object type to use?

Jim Allen
Expert

Apologies if this has been covered elsewhere, I've been looking at a lot of GDL posts and documentation, and I've both learned a lot and been very confused, probably both in equal measure.

 

I want to create an object which is in effect a 2D and 3D gradient labelling tool. I want to insert it onto a mesh, and then stretch the length and rotate as required, then go to the 3D window and use a hotspot to anchor the non-base end of the symbol to a point on the mesh to give me the z height difference to calculate the slope, and have the gradient displayed in 2d and/or 3D with options for angle, percentage or slope ratio.

 

The purpose of this object is twofold, the first is simply to label gradients in 3D. Where I work, most of my sites have slopes and gradients. I often have deal with site gradients and cut and fill, so use terrain modelling on most projects. Designing ramps is a ball-ache, and they are expensive and ugly to construct. If I can design them out, so much the better.

 

Any slope shallower than 1:20 is a 'gradient path' and doesn't need all the complexity of a ramp.

 

I like to use meshes in 3D and push and pull the nodes to shape the terrain as part of my design approach. Having a tool like this would actually make the design process a lot easier because I could push and pull my mesh, adjust the label and check compliance. 

 

I started with the Archicad Slope 25 symbol which I have duplicated and edited. This is a screenshot of the modified object:

Screenshot 2023-01-13 at 10.49.53.png

 

This is broadly how it's scripted:

 

Screenshot 2023-01-12 at 16.25.24.png

 So far so good. I can take the values for the polyline and hotspots and translate them to 3D, and hopefully that will work except I'm not sure which script to use.

 

What I in effect want is to be able to define a 'slab' which will rotate in 3d (or 'tilt') when I move the editing hotspot in the z axis, so it looks something like this:

 

Screenshot 2023-01-13 at 10.27.20.png

Without the circles and labels obviously.

 

The 3D text will be in a similar position to the 2D text if things work out - but inclined in the plane of the arrow. I want the 2D and 3D appearance to be ostensibly the same.

 

There is a lot of information on GDL, but not all of it is clear, simple and comprehensive, and it doesn't seem to tell you what the properties of them all are, and what their limitations are, and what they are best suited to.

 

Should I use a PRISM for this, or can I use an EXTRUDE instead? I just want to translate the 2d xy coordinates to 3D (because it seems easiest and I'm very new at this, and still a bit of a GDL idiot) and have the geometry update itself when I move the 3d hotspot.

 

Alternatively - is there a better option available that I have missed. Aligning the 3d text will require some head-scratching, but one thing at a time.

 

Any help and guidance would be greatly appreciated!

Archicad 27 UKI | OS X 12.7.1 Monterey
40 REPLIES 40

That's an interesting suggestion - I hadn't thought of that, thanks!

Archicad 27 UKI | OS X 12.7.1 Monterey

Another really useful suggestion, I hadn't thought of hard coding the hotpsots, I just used the script from the guides - thanks a lot.

 

You identified the specific problem I was having, in that it was the hotspot coding.

 

Labels are working in 2D and (mostly) 3D, but I'm working on string concatenation with the text label.

 

More head-scratching and swearing going on...

Archicad 27 UKI | OS X 12.7.1 Monterey

I've updated the object, added a bit of explanations there.

About your questions:

1. In order to move one hotspot in different directions (x, z values in our case), you need to make 2 hotspots(HS) descriptions sets (3 rows for each direction). There's an example #2 in GDL manual - graphical editing using HS.

2. I tend to use standard overall dimension parameters. In that case no need to make create a HS for editing. BUT it was a mistake to use ZZYZX here as a z coordinate, because ZZYZX can have only positive values, so i used "zz" insread. Plus when standard parameters A, B, ZZYZX are used, it's easy to modify them at "top row", where parameters of object appear when it's selected.

3. Text positioning - i didn't see how you code it... Anchor value means a lot during DEFINE STYLE.

4. There's enough info about put-get in manual and this forum too. Basically it's buffer where you can store numerical values. After you get how to use it, you won't return to straight forward coding - no need to count number of nodes, esp helpful when you use same shape several times (use method), but the last one must be get - to empty buffer for new "records".

AC 22, 24 | Win 10

@Jim Allen wrote:

The bit I don't understand is poly_ nsp/3, get(nsp) 

 

I understand the POLY_ command, but I don't understand what nsp is, and what the GET command does. It's not a defined variable, and it seems to be used before it gets any data. It doesn't of course, otherwise it wouldn't work, but it does - which has really confused me!


You might be better off not using NSP and simply putting the values you are using in the command. NSP is a way of storing and retrieving values, so the same values can be reused, and the resulting code is shorter. I think for beginners, being able to see all the values in the code directly makes it easier to understand what is going on.

 

David

David Maudlin / Architect
www.davidmaudlin.com
Digital Architecture
AC27 USA • iMac 27" 4.0GHz Quad-core i7 OSX11 | 24 gb ram • MacBook Pro M3 Pro | 36 gb ram OSX14
Jim Allen
Expert

Update:

 

The script works in the sense that it creates labels in 2D and 2D, and the labels are in the right place. 

 

I've attached it but there are some issues to be addressed or improved.

 

1. Currently the script uses ZZYXZ to define the angle. In effect you move the base hotspot, and then drag the vertical height hotspot to define the angle. This came from A_Smith's original script. It's neat and short, but it does mean that you always have to define the base point as the lowest of the slope. It works fine, but it's a workable limitation.

 

2. It would benefit from an additional hotspot to rotate in 2D and 3D. That's not too difficult, but I need to spend the time looking up the syntax of everything when I write GDL.

 

3. The text label, which is supposed to be driven by which option is chosen in the properties, doesn't work and I don't understand why.

This is in my Master script section:

 

!!===================================================
! Gradient label options

G0="Gradient as Angle (degrees)"
G1="Gradient as percentage"
G2="Gradient as ratio (1:n)"
VALUES "Grad_type" G0, G1, G2

!!===================================================

!Set text label depending on type of gradient selected

IF Grad_type = G0 THEN
				slopevalue =str(ang,3,2)
				gradlabel= slopevalue + "degrees"
				
	ELSE Grad_type = G1 
				slopevalue = 100*(ang/360)
				gradlabel= STR(slopevalue,3,2) + "%"
			
	IF Grad_type = G2 THEN 
				slopevalue =100*(ang/360)
				gradlabel= "1:" + STR(slopevalue,3,2)
endif

 

 

The script is supposed to calculate the value of the slope in whatever format is required, and then format the text label gradlabel accordingly.

 

Depending on the gradient format, the text label should change. With degrees it will show  "n degrees", with the grade/percentage option it will show "n %" and with the ratio (which is what our UK Building Regulations use) it will say "1:n". 

 

I have no idea why this isn't working. It's probably something simple.

Archicad 27 UKI | OS X 12.7.1 Monterey

Thanks, that came from A_Smith's script. It worked, but because I didn't fully understand it, I left it the hell alone.

 

I didn't realise it was a command, I found this reference information https://gdl.graphisoft.com/reference-guide/parameter-buffer-manipulation  and immediately thought that it was a lot more programming than I wanted to get my head around!

 

I can see how it would be useful, but it's a long way above my GDL ability level.

 

Once the text label option is fixed, I'll have a useful and usable object out of it though.

 

I'll happily share the completed version in case anyone else might find a use for it.

 

Archicad 27 UKI | OS X 12.7.1 Monterey

You can't write

IF condition THEN

...

ELSE condition ...

 

and so on. You must use instead

IF condition THEN

....

ENDIF - 3 times for three different conditions

 

plus if you want to calculate gradient via angle you should try 

G1: slopevalue = 100 * tan(ang) - not sure about it 🙂 I haven't used % before for slope

G2: slopevalue = 1 / tan(ang) - careful with that. If ang=0 you'll get error

 

edited: tbh I don't get why you need to rotate object in XY plane (along Z axis in 3D), if it's really easy to accomplish wish simple rotation (ctrl+E shortcut) in 2D or 3D window...

 

AC 22, 24 | Win 10

I followed the documentation here:

https://gdl.graphisoft.com/reference-guide/flow-control-statements

which is why is is scripted as it is.

 

I tried a lot of different approaches and that was the only one that didn't generate script errors, but it doesn't work 😊

 

I'll try separate if..then.. lines and see if that works.

 

I looked up the formulas for converting gradient formats.

 

I happily use Ctrl+E all the time (I remember the old days where I used Autocad with 2 letter command abbreviations and it was much faster) but the hotspot might be useful for my colleagues.

 

 

Archicad 27 UKI | OS X 12.7.1 Monterey
Jim Allen
Expert

Update:

 

Everything is working as intended. I have fixed some things and thanks to A_Smith, the IF...THEN statements are now working. That frustrated me, because I haven't had any problem with them in AutoLisp or SketchUp dynamic components or Excel.

 

Thanks very much to everyone who responded!

I've learned a lot of stuff and although it was probably a bit of a stupid first object to script, I do now have something I'll use regularly both as a design tool and a labelling tool.

 

Updated script attached.

Archicad 27 UKI | OS X 12.7.1 Monterey

Yep, that fixed it.

I used the simpler gradient calculation of A/ZZYZX to get the ratio. Sometimes you overlook the simple things 😉

 

I couldn't have done it without you - thanks a lot!

Archicad 27 UKI | OS X 12.7.1 Monterey

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!