BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Problem regenerating story-sensitive object script

Eric Bobrow
Enthusiast
I am in discussions with a firm that is considering ArchiCAD. They design some complex shapes in 3DStudio Max that would need to be imported as objects using the 3DS import Goodie, since these warped forms are beyond what can be done within ArchiCAD easily.

They asked if the imported objects could display correctly on each story based on the active Floor Plan Cut Plane. I said yes, of course, although it would require some GDL scripting. They asked me to send them an example for study.

I have set up a parameter in the imported object called StorySensitive which is turned on when the user wants the object to display differently on each story. My preliminary scripting involves a simple bit of code in the 2D Script:
if StorySensitive then
project2 3,270,1
else
...
which works fine to get a top-down view of the model.

In the 3D Script I have added the following near the beginning to cut off the top of the object at the Floor Plan Cutting Plane height for the story that is currently being drawn (in this early version I am not worrying about cutting off the bottom below the current story):
if StorySensitive and GLOB_CONTEXT = 2 then
add 0,0,GLOB_CUTPLANES_INFO[1]+GLOB_CSTORY_ELEV
cutplane
del 1
endif
There is a matching bit of code at the end of the 3D Script:
if StorySensitive and GLOB_CONTEXT = 2 then
cutend
endif
The problem comes up when I move to different stories in the file (using the Project Map or View Map). In order to see the effect of the script properly, I need to use the ALT-REBUILD command (Rebuild and Regenerate) manually each time I change to a new story. If I do not do this, the object script is not reinterpreted as I change stories. The object looks the same on each story unless I trigger the regeneration.

I could maybe live with this, except that the regeneration is also not seen properly in Views placed as Drawings on the Layout sheets. I placed the floor plan for several stories onto one sheet for study, and the object looks the same on all of them (it should be different for each story). When I go back to a particular story and Rebuild and Regenerate, the object updates correctly for that story, then when I go to the Layout and Rebuild, the object updates on all the floor plans - but always to the latest interpretation (whatever story I was last viewing). It looks the same on all the stories, rather than being cut differently on each one.

So at this point I am stuck - I don't know if there is a way to make the object regenerate based on the story automatically. Are there any GDL experts out there who can help?

By the way I am using AC12 with the latest Hotfix (released this week).

I recall that the MaxonForm import plugin had an option for automatically drawing the imported object based on the floor plan cut plane. We have talked about the possibility of importing the 3DS file via Cinema4D to take advantage of the updated plugin, or even having them use Cinema4D instead of 3DStudio Max, but these would not be the preferred routes. A direct import of 3DS with some quick scripting would be the ideal for them.
8 REPLIES 8
Ben Cohen
Enthusiast
Hi Eric

As an exercise I made a very simple part using your script and I can confirm that the part will not update - in fact my part would not update until I changed the cutplane.
But....... when I added the following script to the 2d to see the values change as I moved from story to story

text2 0,0,GLOB_CUTPLANES_INFO[1]
text2 0,1,GLOB_CSTORY_ELEV

- the part started to update as well!!??. Seems the project2 alone was not enough for the GDL compiler to recognize the fact that an update is required. Maybe try adding in some rudimentary 2d elements (like hotline2) to get the part reacting to the story change correctly. Worth a shot
Ben Cohen
Mac and PC
Archicad (Latest Version) aus
www.4DLibrary.com.au
Ben Cohen
Enthusiast
update

added the following to the master script and it works fine

cutpl = GLOB_CUTPLANES_INFO[1]
st = GLOB_CSTORY_ELEV

- then replaced the variables in the add statement to the corresponding variable names above
Ben Cohen
Mac and PC
Archicad (Latest Version) aus
www.4DLibrary.com.au
I didn't check in 12, but it looks as if it is the same as

http://archicad-talk.graphisoft.com/viewtopic.php?t=8990&highlight=
Eric Bobrow
Enthusiast
Thanks to both of you for your quick responses. I haven't had a chance to test it yet, but am certain that this will work.

In retrospect, it looks obvious - the GDL compiler looks for anything that would be affected by changing contexts, and notes when it needs to reinterpret the script. If there is nothing in the 2D script that appears to depend on the current story, it thinks that the object's representation on the floor plan is constant and doesn't run the script again when you go to a different story.

It isn't smart enough to realize the link between the Project2 statement and the story-sensitive changes in the 3D script (the Cutplane statements that refer to Global variables for the current story), so one has to trigger the script reinterpretation with something it can "see".

I think I'll just use the simple dummy variable statement from the earlier thread:

dummyvar = GLOB_CSTORY_ELEV

since there is no need to break up the logic (and complicate the editing) into more areas in the library part. I want to create as simple and quick a process as possible for the user to follow after importing an object from 3DS. At this point, it looks like copying and pasting a few lines at the beginning and end of the 2D script and 3D script, plus the addition of one parameter (StorySensitivity), will be enough to make this functional.

As a wishlist item: build this story-sensitivity into library parts as a standard option, just like walls, windows and doors etc. have a choice of Symbolic or Projected representation.
Eric Bobrow
Enthusiast
I have verified that the simple dummy variable statement is enough to trigger the GDL interpreter to run as one changes stories. So my script is working now. Hooray!

For the record, and as a Tip for future reference, here is my 3D script for a test object that creates an inverted step pyramid. I created it so it would be easy to see the results on the floor plan as the Floor Plan Cut Plane parameters are adjusted.
if StorySensitive and GLOB_CONTEXT = 2 then
	add 0,0,GLOB_CUTPLANES_INFO[1] + GLOB_CSTORY_ELEV - GLOB_HSTORY_ELEV
	cutplane
	del 1
	if CutBelow then
		cutbottom = max(GLOB_CUTPLANES_INFO[3]+GLOB_CSTORY_ELEV-GLOB_HSTORY_ELEV,GLOB_CUTPLANES_INFO[4])
		add 0,0,cutbottom
		mulz -1
		cutplane
		del 2
	endif
endif

! STEP PYRAMID for testing
	ft=1'-0"
	steps=zzyzx/ft
	for i=1 to steps
		block i*ft,i*ft,ft
		addz ft
	next i
	del steps
! End of STEP PYRAMID

if StorySensitive and GLOB_CONTEXT = 2 then
	cutend
	if CutBelow then
		cutend
	endif
endif
Note that StorySensitive is a parameter to choose whether the object should be cut based on the Floor Plan Cut Plane - if it's not set then the object will be invariant for all stories. CutBelow is a parameter to choose whether to remove the underside of the object below the current story limit (or the Absolute Display Limit, whichever is more restrictive).

If the 3D script code is to be used with an imported 3DS object (or any other scripted object) then the beginning section above goes after the standard line:
IF AC3D_SHOW3D THEN
and the final section goes at the very end of the 3D script.

The 2D script is very simple. If one prefers showing the top view at all times, ignoring any LINE statements created by importing a 3DS geometry, then it is simply
dummyvar = GLOB_CSTORY_ELEV
project2 3,270,1
If, on the other hand, one wants to have the option of using the LINE2 and HOTSPOT2 statements from the 3DS import (or any other parametric scripting), then the beginning of the 2D script becomes:
if StorySensitive then
	dummyvar = GLOB_CSTORY_ELEV
	project2 3,270,1
	end
endif
with the rest of the original 2D GDL code from the import left intact.

Of course, more elaboration is possible, but this will give basic Cutplane functionality to any library part.

I was particularly fascinated to find in the ArchiCAD 12 GDL Reference Guide a new (to me) command PROJECT2{3} which allows the PROJECT2 statement to choose which parts of the object to include (cut polygons, cut polygon edges, view polygons and/or view polygon edges) with extensive controls for the projection hatches, fills and linework. It also offers the possibility of drawing the projection based on a different set of parameter values than are currently set for the library part. Wow! I'm not sure exactly how to take advantage of this, but it opens up a new world of options. I wonder if this is new in AC12 or was put into an earlier version but I missed it.
Anonymous
Not applicable
Hello from future !

Thank you Eric
Eric Bobrow
Enthusiast
Hello NeckoFromSarajevo -
I have caught up with you here in the future (2014)...
Hard to believe we're up to AC17, with 18 around the corner!
Eric
Anonymous
Not applicable
Hello from even farther future

I'm using ArchiCAD 21!

Eric, I'm trying to make my imported building 3D model story sensitive. I tried to follow your instructions but I'm guessing newer versions of ArchiCAD changed some parameter policies. I can't seem to make the script work.
I'm pretty familiar with ArchiCAD but this is my 1st time getting "dirty" into scripting

Can you please confirm that the instruction is still relevant to newer versions of ArchiCAD?

I did some digging in Graphisoft's GDL Center and found this information: 3D Projections in 2D Maybe I should be using PROJECT2{#} command instead?

Thank you in advance and wish you a productive day!
Learn and get certified!