How do I measure a non-updated point in CATIA VBA?

904 views Asked by At

I'm trying to make a point measuring tool, but whenever my loop stumbles upon a non-updated point, it crashes my Measurable. How can I measure it?

2

There are 2 answers

0
Nicholas Pisca On

After searching around, it appears you can't measure any geometry that isn't updated.

You can update one object by using the UpdateObject method in the MecMod Part library. Then run the measurable methods now that you have an updated object.

Like this:

CurPart.UpdateObject Obj1

If the geometry cannot update, due to an issue with the geometry, you can always skip it with error checking (sloppy), or use the command "IsUpToDate" to check if the geometry is updated.

Like this:

If CurPart.IsUpToDate(Obj1) = true then
     Meas.GetPoint PTArr
End If

Be sure to keep the object name in an array so you can prompt the user with a list of all objects that did NOT get measured.

1
tsolina On

you can always isolate geometry, then you can measure and delete it if you dont need it anymore..

here is an example which creates isolated copy of first point in first geometrical set, updated or not, while original stands intact.

Sub makePointDatum()
    Dim sPoint As HybridShapePointExplicit, oPart As Part, oHSF As HybridShapeFactory
    Set oPart = CATIA.ActiveDocument.Part
    Set oHSF = oPart.HybridShapeFactory

    Set sPoint = oHSF.AddNewPointDatum(oPart.HybridBodies.Item(1).HybridShapes.Item(1))
    oPart.UpdateObject sPoint
    oPart.HybridBodies.Item(1).AppendHybridShape sPoint
End Sub