cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

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

failing to get part of this script to run ONCE!

Anonymous
Not applicable
Ok so I'm new to this but it CAN'T be this hard!
My object is an external cladding screen consisting of a steel frame and automatically generated (random within user set parameters) vertical timber slats on the outside.

I have the graphical editing working so that I can stretch the frame and more slats generate - nice. Now I have created dynamic hotspots for users to edit individual slats. They show up ok but moving them generates no result BECAUSE it is constantly recalculating the slat positions (Funny how they all stay the same when I've used a RND function to generate them!... another time). So I've introduced a variable called Regen which when = 0 will run the slat calculation and put a line in the slat calculation which makes Regen = 1, thinking that this will stop the calculation running.
It refuses to work. Regen is somehow reset to zero on each attempted edit so the dynamic hotspots have no effect.

Yes Regen is uninitialized.

I must be missing something basic. Any help?
8 REPLIES 8
Erich
Contributor
Take a look at how I handle the lines for the hangers in the simple closet object here. I think this will resolve your issue.

Rabbit Hole
Erich

AC 19 6006 & AC 20
Mac OS 10.11.5
15" Retina MacBook Pro 2.6
27" iMac Retina 5K
Anonymous
Not applicable
Thanks Erich, But I don't see it yet.

It looks to me like your random line generator for the 2d clothes representation runs every time.

An equivalent to my situation would be if you then introduced dynamic hotspots to allow user editing of the 2d clothes lines. If your random routine keeps running it would not allow a successful user edit - my problem. How do you get it to do the first run of random generation and then allow user editing?
Ralph Wessel
Mentor
Angry wrote:
I've introduced a variable called Regen which when = 0 will run the slat calculation and put a line in the slat calculation which makes Regen = 1, thinking that this will stop the calculation running.
It refuses to work. Regen is somehow reset to zero on each attempted edit so the dynamic hotspots have no effect.
When you set Regen to 1, do you also update the object parameter, e.g.
parameters regen = 1
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Thanks Ralph,

I am using the "parameters Regen = 1" statement

The code looks like this:
(3d script)

-------------------
If Regen = 0 then
gosub 2000 ! recalculate slat lengths
Regen = 1
Parameters Regen = 1
endif
-------------------

Perhaps the 'parameters' instruction has a limitation on which script it works in?
Ralph Wessel
Mentor
Angry wrote:
I am using the "parameters Regen = 1" statement
Perhaps the 'parameters' instruction has a limitation on which script it works in?
Yes, it does. It will only take effect during some kind of editing operation, i.e. when the use is changing the settings or stretching in 2D/3D.
Ralph Wessel BArch
Software Engineer Speckle Systems
Barry Kelly
Moderator
Angry wrote:

Perhaps the 'parameters' instruction has a limitation on which script it works in?
Yes it will only work in the Parameter or Master scripts - not the 2D or 3D scripts.

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Ralph Wessel
Mentor
Barry wrote:
Angry wrote:

Perhaps the 'parameters' instruction has a limitation on which script it works in?
Yes it will only work in the Parameter or Master scripts - not the 2D or 3D scripts.
Not quite true. You can put a parameters statement in the Master script, but it will only work when an editing operation has occurred. Editing is the crucial ingredient for a parameters statement to work, e.g. the Master script also runs when the object is displayed in 2D or 3D but parameter statements in that context will have no effect.
Ralph Wessel BArch
Software Engineer Speckle Systems
Anonymous
Not applicable
Follow-up:
It was working all along!!
The issues were:
The PRINT alert I had in the Parameter script to tell me the global-modpar had been detected didn't work - seems PRINT will not work in the parameter script.
And ACs static RND results were giving exactly the same 'random' numbers for my slat lengths!! (the results are only new when you place a new instance if the object). Got my own 'random' function now.
So the whole thing was working, just not changing or giving me my print alert!
So that's all fixed. Now on to the next vexing problem with the dynamic hotspots re-setting all my array values to zero?? - new post time.