Ian Cuz
Aerospace
- Dec 6, 2017
- 18
Further to my recent post - refer to "thread560-433573"
I wish to avoid using SPAWorkBench to return a Distance Measure Value
I also wish to create a loop whereby I Measure between a Surface and a number of Points sequencially
I recorded the manual method and altered it as per the advise in the thread above but it
does not create the Formula Relation correctly
Can anyone please advise - thanks
My test code below and attached:-
Language="VBSCRIPT"
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set parameters1 = part1.Parameters
Set length1 = parameters1.CreateDimension("DIST_PARAMETER", "LENGTH", 0.000000)
Set relations1 = part1.Relations
' Recorded Create Formula code line
'Set formula1 = relations1.CreateFormula("FORMULA", "", length1, "distance(`Surfaces\Sweep-ISOLATED` ,Points1\Point.1 ) ")
'* To put this functionality into a Loop, I need to pass different objects into the CreateFormula method
'* Further to Forum Thread = thread560-433573, I have built a String to represent the Object Name (including Parent GeoSet)
strSurfaceObjectName = "Surfaces\Sweep-ISOLATED"
'* Test Message
' MsgBox "Surface Name = " & strSurfaceObjectName
strPointObjectName = "Points1\Point.1"
'* Test Message
' MsgBox "Point Name = " & strPointObjectName
' Create Formula Using A Manually Built String - As Per Advise For AREA Measurement
Set formula1 = relations1.CreateFormula("Dist_Formula", "", length1, "distance( " & strSurfaceObjectName & ", " & strPointObjectName & ") ")
'* Test Message
MsgBox "Distance Measure Value = " & length1.Value
part1.Update
End Sub
I wish to avoid using SPAWorkBench to return a Distance Measure Value
I also wish to create a loop whereby I Measure between a Surface and a number of Points sequencially
I recorded the manual method and altered it as per the advise in the thread above but it
does not create the Formula Relation correctly
Can anyone please advise - thanks
My test code below and attached:-
Language="VBSCRIPT"
Sub CATMain()
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set parameters1 = part1.Parameters
Set length1 = parameters1.CreateDimension("DIST_PARAMETER", "LENGTH", 0.000000)
Set relations1 = part1.Relations
' Recorded Create Formula code line
'Set formula1 = relations1.CreateFormula("FORMULA", "", length1, "distance(`Surfaces\Sweep-ISOLATED` ,Points1\Point.1 ) ")
'* To put this functionality into a Loop, I need to pass different objects into the CreateFormula method
'* Further to Forum Thread = thread560-433573, I have built a String to represent the Object Name (including Parent GeoSet)
strSurfaceObjectName = "Surfaces\Sweep-ISOLATED"
'* Test Message
' MsgBox "Surface Name = " & strSurfaceObjectName
strPointObjectName = "Points1\Point.1"
'* Test Message
' MsgBox "Point Name = " & strPointObjectName
' Create Formula Using A Manually Built String - As Per Advise For AREA Measurement
Set formula1 = relations1.CreateFormula("Dist_Formula", "", length1, "distance( " & strSurfaceObjectName & ", " & strPointObjectName & ") ")
'* Test Message
MsgBox "Distance Measure Value = " & length1.Value
part1.Update
End Sub