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

3D polyline using

Anonymous
Not applicable
Hi, I wanted to use in my object the 3D polyline that I have found some time ago on this forum (credit to the author).

I would like to enable user to put in a certain segment a geometry (for example a sphere).
Let's assume there are 8 segments, and I pick the 6th one to place there a sphere.
The problem is that when I reduce the number of points then the sphere jumps forward to another segment (because obviously the 6th segment is in different place now).

I'm run out of ideas how can I make it stay in the previous position, anyone can help me?
6 REPLIES 6
sinceV6
Advocate
"the author" here.

In essence, the interpretation is correct because the geometry gets placed on the specified segment. You can modify any of the segments after the selected one and the geometry will stay on the specified segment. If you modify any segment before the selected one, obviously the numbering of segments changes and so does the sphere's placement.

To correct this, you would need to identify which point is being moved or which segment is about to be removed. If it is one before where the user has selected to place the sphere, you'd need to modify the selected segment for placement (to the previous one). You'd need to put special attention on what to do when the user is about to remove the segment where the sphere is currently placed.

Best regards.
jasiek772 wrote:
Hi, I wanted to use in my object the 3D polyline that I have found some time ago on this forum (credit to the author).

I would like to enable user to put in a certain segment a geometry (for example a sphere).
Let's assume there are 8 segments, and I pick the 6th one to place there a sphere.
The problem is that when I reduce the number of points then the sphere jumps forward to another segment (because obviously the 6th segment is in different place now).

I'm run out of ideas how can I make it stay in the previous position, anyone can help me?
IF GLOB_MODPAR_NAME = "IXYZ" THEN

	FOR i=1 to points
		IF ABS(IXYZ-IXYZP)>EPS OR ABS(IXYZ-IXYZP)>EPS THEN
			insertIndex_2=i
			newX_2=IXYZ
			newY_2=IXYZ
			newZ_2=IXYZ

		ENDIF
	NEXT i


	IF insertIndex_2>0 THEN
	points=points+1


		FOR i=points TO insertIndex_2+2 STEP -1
			XYZ=XYZ[i-1]
			XYZ=XYZ[i-1]
			XYZ=XYZ[i-1]

		NEXT i

		XYZ[insertIndex_2+1]=newX_2
		XYZ[insertIndex_2+1]=newY_2
		XYZ[insertIndex_2+1]=newZ_2


	ENDIF
ENDIF
!===================================================================
!===FOR REMOVING POINTS=============================================
remainingPoints_2=1


FOR i=1 TO points-1

	hypotenuse_2 = sqr((XYZ[i+1]-XYZ)^2 +(XYZ[i+1]-XYZ)^2)
	IF hypotenuse_2>EPS THEN
		remainingPoints_2 = remainingPoints_2+1
		PUT XYZ[i+1],XYZ[i+1],XYZ[i+1]
	ENDIF

NEXT i

!PRINT remainingPoints

FOR i=2 TO remainingPoints_2
	XYZ=GET(1)
	XYZ=GET(1)
	XYZ=GET(1)
NEXT i

points=remainingPoints_2
Its in here somewere took me a min to figure it out
You need to mark position of the change - and check if it is before or after the object placement. If after do nothing...if before the number of placing segment must go down by 1 if the node is subtracted or go up by 1 if added.

(I did not analyze the object You quoted, but I made something similar some time ago...times of ver 12)

Best Regards,
Piotr
Anonymous
Not applicable
SenecaDesignLLC wrote:
IF GLOB_MODPAR_NAME = "IXYZ" THEN

	FOR i=1 to points
		IF ABS(IXYZ-IXYZP)>EPS OR ABS(IXYZ-IXYZP)>EPS THEN
			insertIndex_2=i
			newX_2=IXYZ
			newY_2=IXYZ
			newZ_2=IXYZ

		ENDIF
	NEXT i


	IF insertIndex_2>0 THEN
	points=points+1


		FOR i=points TO insertIndex_2+2 STEP -1
			XYZ=XYZ[i-1]
			XYZ=XYZ[i-1]
			XYZ=XYZ[i-1]

		NEXT i

		XYZ[insertIndex_2+1]=newX_2
		XYZ[insertIndex_2+1]=newY_2
		XYZ[insertIndex_2+1]=newZ_2


	ENDIF
ENDIF
!===================================================================
!===FOR REMOVING POINTS=============================================
remainingPoints_2=1


FOR i=1 TO points-1

	hypotenuse_2 = sqr((XYZ[i+1]-XYZ)^2 +(XYZ[i+1]-XYZ)^2)
	IF hypotenuse_2>EPS THEN
		remainingPoints_2 = remainingPoints_2+1
		PUT XYZ[i+1],XYZ[i+1],XYZ[i+1]
	ENDIF

NEXT i

!PRINT remainingPoints

FOR i=2 TO remainingPoints_2
	XYZ=GET(1)
	XYZ=GET(1)
	XYZ=GET(1)
NEXT i

points=remainingPoints_2
Its in here somewere took me a min to figure it out
Could you please spend another min to explain it to me somehow? Because to me it looks like you simply replaced some one-dimensional arrays into two-dimensional in existing script, but why? Or maybe you don't mean to replace existing lines but just to add your lines below?

Thank you all for your consideration!
"Piotr Dobrowolski" and "SenecaDesignLLC" of course I know it should be divided into few different cases, whether reducing or adding points in certain places changes anything or not, so the question is not when I should divide it, or what should I take under consideration writing the script, but how to write it?
sinceV6
Advocate
Hi.

In that old version of the script, you can start with something as simple as these couple of edits:
!===FOR ADDING POINTS===============================================
IF GLOB_MODPAR_NAME = "insertX" OR GLOB_MODPAR_NAME = "insertY" THEN
	FOR i=1 to points
		IF ABS(insertX-insertXPrev)>EPS OR ABS(insertY-insertYPrev)>EPS THEN
			insertIndex=i
			newX=insertX
			newY=insertY
			newZ=insertZ
		ENDIF
	NEXT i

	IF insertIndex>0 THEN
	points=points+1
		FOR i=points TO insertIndex+2 STEP -1
			x=x[i-1]
			y=y[i-1]
			z=z[i-1]
		NEXT i
		x[insertIndex+1]=newX
		y[insertIndex+1]=newY
		z[insertIndex+1]=newZ
		
	!!!THESE LINES--------------------------------------	
	If insertIndex<brnr THEN
		brnr=brnr+1
	ENDIF
	!-----------------------------------------------------------

	ENDIF
ENDIF
!===================================================================

!===FOR REMOVING POINTS=============================================
remainingPoints=1
FOR i=1 TO points-1
	hypotenuse = sqr((x[i+1]-x)^2 +(y[i+1]-y)^2)
	IF hypotenuse>EPS THEN
		remainingPoints = remainingPoints+1
		PUT x[i+1],y[i+1],z[i+1]
		
	ENDIF

!!!THESE LINES-------------------------------------
	IF hypotenuse<EPS AND brnr>i THEN
		brnr=brnr-1
	ENDIF
!!!--------------------------------------------------

NEXT i
Although I changed the parameter script to:
!my VALUES


!!!VALUES 'brnr' listar
VALUES 'brnr' RANGE[1,segments]
PARAMETERS brnr=brnr
See if that works for you.
Best regards.
Anonymous
Not applicable
Well it turns out that I forgot just one thing:
"PARAMETERS brnr=brnr "
Such a stupid oversight...

Thank you very much for your help!