2016-09-13 07:12 PM
2016-09-14 02:03 AM
2016-09-14 03:48 AM
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(IXYZIts in here somewere took me a min to figure it out-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
2016-09-14 09:48 AM
2016-09-14 02:23 PM
SenecaDesignLLC wrote: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?
IF GLOB_MODPAR_NAME = "IXYZ" THEN FOR i=1 to points IF ABS(IXYZIts in here somewere took me a min to figure it out-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
2016-09-14 09:39 PM
!===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 iAlthough I changed the parameter script to:
!my VALUES !!!VALUES 'brnr' listar VALUES 'brnr' RANGE[1,segments] PARAMETERS brnr=brnrSee if that works for you.
2016-09-15 01:07 AM