Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5806

Curve doesn't get selected in the loop

$
0
0

@Clive wrote:

Hi,
Can someone please help with this?
Two separate functions generate 2 3D objects,
The third function runs Boolintersection over them.

The 1st curve is expected to be updated by CageEdit.
Here is the code:

Dim arrObjects,strObject,strSurf
Dim Objects,subObj,arrPoints
Dim arrPath`
arrPath = array(0, 0, 10)

Call main()
Sub main()

    Dim i,Result,arrObjects1
    arrObjects1 = Rhino.GetObjects("Pick 1st curve(s)", 4, False, True)
    arrObjects2 = Rhino.GetObjects("Pick 2nd curve(s)", 4, False, True)
    'Rhino.EnableRedraw False
    For i=0 To 5
	Boolintersection arrObjects1, arrObjects2, i
    Next
    'Rhino.EnableRedraw True
End Sub

Function Pol(arrObjects1, i)
    If IsNull(arrObjects1) Then Exit Function
    For Each strObject In arrObjects1

	'' Apply CageEdit

	Rhino.SelectObject strObject
	Rhino.Command("_CageEdit _Boundingbox _World _X=2 _Y=2 _Z=2 _Enter _Global _Enter")

	'' Move Control Points

	Objects = Rhino.LastCreatedObjects
	If Isarray(Objects) Then
		Rhino.SelectObjectGrip Objects(0), 4
		arrPoints = Rhino.ObjectGripLocation(Objects(0), 4)
			If Isarray(arrPoints) Then
				arrPoints(0) = arrPoints(0) - i
			Rhino.ObjectGripLocation Objects(0), 4, arrPoints
			End If
	End If

	'' Make 3D Object

	strSurf = Rhino.ExtrudeCurveStraight(strObject, arrPath)
	Rhino.CapPlanarHoles strSurf
    Next
    Pol = strSurf
End Function

Function Cir(arrObjects2)

    If IsNull(arrObjects2) Then Exit Function
    For Each strObject In arrObjects2

	'' Make 3D Object

	strSurf = Rhino.ExtrudeCurveStraight(strObject, arrPath)
	Rhino.CapPlanarHoles strSurf
    Next
    Cir = strSurf
End Function

Function Boolintersection(arrObjects1, arrObjects2, i)
    Dim curveA,curveB,arrObj
    curveA = Pol(arrObjects1, i)
    curveB = Cir(arrObjects2)
    arrObj = Rhino.BooleanIntersection(curveA, curveB)
    If IsNull(arrObj) Then
	Rhino.Print "Curves do not intersect"
    End If
End Function

The following part In Function Pol(arrObjects1, i)seems to be skipped in the second step.
because Rhino.SelectObject strObject is ignored by some reasons,


Objects = Rhino.LastCreatedObjects
	If Isarray(Objects) Then
		Rhino.SelectObjectGrip Objects(0), 4
		arrPoints = Rhino.ObjectGripLocation(Objects(0), 4)
			If Isarray(arrPoints) Then
				arrPoints(0) = arrPoints(0) - i
			Rhino.ObjectGripLocation Objects(0), 4, arrPoints
			End If
	End If

This is what command line shows when the code is run in the first loop:

and the second loop:

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5806

Trending Articles