2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations
2023-01-13 12:45 PM
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:
This is broadly how it's scripted:
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:
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!
2023-01-18
05:33 PM
- last edited on
2023-01-21
01:53 PM
by
Laszlo Nagy
! first in PARAMETER section add "angle" like an angle (not distance)
! TRY THIS IN YOU 3D SCRIPT
!----------- ADD THIS IN 3D-------------
!add a hotspot in the plane XZ
HOTSPOT A*0.5, 0, 0, 1,angle,4 !base
HOTSPOT A*COS(angle), 0, A*SIN(angle), 2,angle,5, angle !move
HOTSPOT 0, 0, 0, 3,angle,6 !center
HOTSPOT 0, -A*0.1, 0, 4,angle,7 !reference add a vector in the Y axis to make correct rotation
MATERIAL 60 !first material
ROTY -angle !this rotation in the Axis Y is equal to the hotspot
PRISM_ 7, 0.01,
0,0,15,
B/2, -B/2, 15,
A-B/2, -B/2, 15,
A, 0, 15,
A-B/2, B/2, 15,
B/2, B/2, 15,
0, 0, 15
MATERIAL 2 !second material
ADDX A/2 !we move the text to the center because in our style the anchor is at the center (5)
ADDZ 0.015 ! just move up the text over the slope
DEFINE STYLE "mytext" "Arial", B*600, 5, 0 !we define out style for 3d , 60% of B will be the height
SET STYLE "mytext"
TEXT 0, 0, "text or data for the slope" !you can change this text for any data you choose like in your 2D
DEL 2 !we erase transformations of text
DEL 1 !erase transformation of rotation
! with the variable "angle" you obtain the data for your script in 2D that its working
2023-01-19 02:23 AM
@A_ Smith wrote:
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
That is fine if you only have three conditions to be met, and it can't be anything else.
But what happens if there is another.
You can nest IF/THEN.
IF condition THEN
...
ELSE
IF condition THEN
...
ELSE
IF condition THEN
...
ELSE
...
ENDIF
ENDIF
ENDIF
This way, if it does not meet the first condition, it will check the second condition.
If it doesn't meet the second condition, it will check the third.
It it doesn't meet the third condition (i.e. it does not meet any of the previous conditions) then it will apply the last condition.
You can keep going if that are more possible conditions you want to catch.
Barry.
2023-01-19 02:35 AM
Just make sure you indent everything properly, as it becomes very easy to lose track of the number of IF statements. The same for transformations.
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2023-01-19 02:38 AM
@Lingwisyer wrote:
Just make sure you indent everything properly, as it becomes very easy to lose track of the number of IF statements. The same for transformations.
Yes, it is important to set the scripts out legibly - and add comments.
I am still waiting for colour coded scripts.
One day!
Barry.
2023-01-19 10:22 AM
Re: GDL Syntax Highlight for VSCode @Barry Kelly see PB's last comment. Fingers crossed!
2023-01-19 10:27 AM
Yes, I saw that.
I really hope it does happen.
Barry.
2023-01-19 02:36 PM
Ideally yes, nested IF-else statements are definitely better. Though, tbh i make just IF, in case of many IF, otherwise will be hard to read - there no CASE statement and sometimes i have more than 40 IFs... I don't want to imagine how it will look like properly nested, though caution needed indeed + it's not effective coding - if IF condition finds its match, others IF still will be checked. I haven't found better option than independent IFs if there's a lot of conditions...
2023-01-20 02:11 AM
40 IF statements... If you're going that far I feel like you should be using numerical strings and comparing ranges in order to reduce the number of possible operations.
IF x > 20 then
IF x < 10 then
IF x = 1...
IF x = 2...
...
ELSE
...
endIF
ELSE
IF x ≥ 10 then
...
endIF
endIF
Ling.
AC22-23 AUS 7000 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2023-01-20 08:30 AM - edited 2023-01-20 08:31 AM
About 40 IF - towel rails (warmer) object which has many models. All IF are compared via equal sign with variable, which is integer.
I mean in Master script modelName1=1, in other scripts IF model=modelName1 THEN...
And ofc to ease process i didn't do 40 nests
2023-01-20 08:51 AM
If you have 40 specific model names (in a list), then 40 separate IF statements is fine.
If you were allowing the user to type in a model name, then that is when you need the IF/THEN/ELSE, so you can catch the name that does not match what you are expecting.
Speed wise, yes it will check each of the separate IFs and it will stop in the nested ones when it finds a match and will ignore the rest.
But I don't think you will notice much of a difference from the users view point.
Barry.