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

Help with a script for accessories objects keep correct data

JaseBee
Advocate
Hi Talkers,

I have a tricky one, I'm wanting to use the polyline accessories add-on to create objects that follow a path. I've made a few objects with a completely GDL dynamic poly line script that I found on this forum, but I think the approaching the same problem with a proper poly line at it's heart would be better for a number of reasons. Mainly it will be easier for the other users in the office to understand how to manipulate it.

Anyway, the problem is as you add or subtract points on the polyline any data relating to that line shifts according to the number of points added/subtracted (for instance any height values).

So I wrote this (applied to an object with polyline accessory subtype with 2 new parameters; ac_check[1][3] (dimension), ac_index[1] (integer)
		DIM _ac_new [][],
			_ac_index []

		_max_coords = VARDIM1(ac_coords)
		_max_check = VARDIM1(ac_check)

		_delta = _max_coords - _max_check

		_new_index = 0

		IF _delta = 0 THEN 															!No New or Deleted Points
			FOR i = 1 TO _max_coords
				_ac_new [1] = ac_coords [1]
				_ac_new [2] = ac_coords [2]
				_ac_new [3] = ac_coords [3]

				_ac_index  = ac_index 
			NEXT i
		ELSE 																		!New or Deleted Points
			FOR i = 1 TO _max_coords												!Check through all current points
				_new_point = 1														!Default is a new point
				FOR j = 1 TO _max_check												!Check check against all previous points
					IF ac_coords [1] > ac_check [1] - EPS & \
						ac_coords [1] < ac_check [1] + EPS & \
						ac_coords [2] > ac_check [2] - EPS & \
						ac_coords [2] < ac_check [2] + EPS & \
						ac_coords [3] > ac_check [3] - EPS & \
						ac_coords [3] < ac_check [3] + EPS THEN 				!Point is the same
						
						_ac_new [1] = ac_coords [1]							!Assign the previous values from current points
						_ac_new [2] = ac_coords [2]
						_ac_new [3] = ac_coords [3]

						_ac_index  = ac_index 								!Assign the previous values from Previous settings
					 	
					 	_new_point = 0												!Point is NOT new
					ENDIF
				NEXT j
				IF _new_point = 1 THEN 												!Point is new
					_ac_new [1] = ac_coords [1]
					_ac_new [2] = ac_coords [2]
					_ac_new [3] = ac_coords [3]

					_ac_index  = _new_index
				ENDIF
			NEXT i
		ENDIF

		ac_check = _ac_new															!Store changed values
		ac_index = _ac_index

		PARAMETERS \																!Write parameters with changed values
			ac_check = ac_check,
			ac_index = ac_index

		FOR i = 1 TO VARDIM1(ac_coords)												!Write index on each point
			HOTSPOT2 ac_coords[2], ac_coords[3]
			TEXT2 ac_coords[2], ac_coords[3], ac_index 
		NEXT i
It sorta works, but because the object doesn't rerun it's parameter script when you change the base polyline it produces errors if multiple changes are made to the line without getting the object to rerun it's parameter script (so it can store the new point data for checking prior to the next change).

So yeah, any help or advice would be greatly appreciated, the easiest fix I can see would be to somehow force the parameter script to run every time the polyline is manipulated, but I haven't come across any way to do that.

I had tried a different method of checking, which was flawed but also ran into the same underlying problem.

Thanks in advance.
Jase.
AC 24 5004 AUS
iMac OSX (10.13.6) 4.2ghz i7
8gb ram/8gb vram
1 REPLY 1
JaseBee
Advocate
Ok, I found a solution...

Nestled deep deep down in the library developer tools there is a command to rerun parameter scripts of all placed library parts, provided you run this in-between changing the polyline in different ways (i.e. after you've moved a bunch of point but before you add more, or after you've deleted some but before you move others) then everything should retain it's value...

Only problem is I've only tested it in a blank file and the rerun takes a bit of time, like a lot, can only imagine how long you'd be sitting there in a file with a lot of objects. would be quicker just to open and close the object...

Maybe I just make the thing go red when you change the polyline as a visual cue to open it... I understand what needs to happen, but others in the office that don't understand the way these objects work might struggle with it...
AC 24 5004 AUS
iMac OSX (10.13.6) 4.2ghz i7
8gb ram/8gb vram

Start a new conversation!

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!