Reputation: 59
I am writing VBA code for Catia V5 to define an endpoint on a reference line.
The section of code looks as follows:
Dim oReference1 As Reference
Dim oHybridShapeFactory As HybridShapeTypeLib.HybridShapeFactory
Dim intPoint As HybridShapePointOnCurve
Dim oCount As Double
oCount = 10
LenVal = GetLengthValue(oPart, MessRef) 'LenVal stems from a function and is equal to 654.5 (for instance) of Type Double
Dim NoOfSections As Integer
NoOfSections = LenVal / oCount
Dim i As Double
For i = 0 To NoOfSections
Set intPoint = oHybridShapeFactory.AddNewPointOnCurveFromDistance(oReference1, (i * (LenVal / NoOfSections)), False)
...
There is an error message on the Set intPoint...
line stating:
runtime error 91: object variable or with-block variable not defined
I have been digging through the help documentation. Everything seems to be defined as required - the Function AddNewPointOnCurveFromDistance takes a Reference, a double, and a boolean as HybridShapePointOnCurve.
Upvotes: 0
Views: 1064
Reputation: 1101
You define the objects but you don't set the object values.
So before you go into the loop...
'Set the HSF
Set oHybridShapeFactory = oPart.HybridShapeFactory
'Get the curve
Dim oCurve as HybridShape
Set oCurve = oPart.FindObjectByName("MyInputCurve") ' this is not the only way to get a curve object
Set oReference1 = oPart.CreateReferenceFromObject(oCurve)
Upvotes: 1