Face.CalculateStrokes() not working

Face.CalculateStrokes() not working

william
Advocate Advocate
248 Views
2 Replies
Message 1 of 3

Face.CalculateStrokes() not working

william
Advocate
Advocate

I have this code... 

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef = oDoc.ComponentDefinition

Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face")
oDoc.SelectSet.Select(entity)

Dim oFace As Face

Try
	oFace = ThisApplication.ActiveDocument.SelectSet.Item(1)
Catch
	MsgBox("A face must be selected.")
End Try

Dim lVertexCount As Long
Dim lSegmentCount As Long
Dim adVertexCoords() As Double
Dim alVertexIndices() As Long
oFace.CalculateStrokes(0.01, lVertexCount, lSegmentCount, adVertexCoords, alVertexIndices)

 

And I keep getting this error 

Capture.PNG

 

According to the API help the vertexindices are supposed to be 'Long'

Capture3.PNG

 

However the code tooltip says the vertexindices are type integer. 

Capture1.PNG

 

When I change vertexindices to integer and run the rule I get this error. 
Capture2.PNG

 

Can someone confirm what this should be and how to make it work? 

0 Likes
Accepted solutions (1)
249 Views
2 Replies
Replies (2)
Message 2 of 3

Michael.Navara
Advisor
Advisor
Accepted solution

Difference between Integer and Long is in its size. In VBA the Integer is 16bit and in iLogic/VB.NET Integer is 32bit length. This means VBA Long is the same as VB.NET Integer.

At second you need to initialize the arrays before. See the iLogic sample below.

 

Sample code

Dim oDoc As PartDocument = ThisDoc.Document
Dim oCompDef = oDoc.ComponentDefinition

Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face")
oDoc.SelectSet.Select(entity)

Dim oFace As Face

Try
    oFace = ThisApplication.ActiveDocument.SelectSet.Item(1)
Catch
    MsgBox("A face must be selected.")
End Try

Dim lVertexCount As Long
Dim lSegmentCount As Long
Dim adVertexCoords() As Double = {}
Dim alVertexIndices() As Integer = {}
oFace.CalculateStrokes(0.01, lVertexCount, lSegmentCount, adVertexCoords, alVertexIndices)

'FOR DEBUG ONLY
Logger.Debug("lVertexCount = " & lVertexCount)
Logger.Debug("lSegmentCount = " & lSegmentCount)
Logger.Debug("adVertexCoords = Double(" & adVertexCoords.Length & ")")
Logger.Debug("alVertexIndices = Double(" & alVertexIndices.Length & ")")

 

0 Likes
Message 3 of 3

william
Advocate
Advocate

Thanks. I wouldn't have picked that. 

0 Likes