Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

CATIA MACRO: create a new point from a reference point

Status
Not open for further replies.

DiaeArrahmane

Automotive
Apr 4, 2024
17
Hello yall, I try to create a new point from a reference point using AddNewPointCoordWithReference but it doesn't work, and I think it's because the reference point A is in part1, while the new point B is in part2. I tried AddNewPointDatum but it seems to be the same problem. How can I do this while every point is in separate part.
 
Replies continue below

Recommended for you

can you share your code?

Eric N.
indocti discant et ament meminisse periti
 
The error says the add point function fails.

Code:
Sub CATMain()

Dim Hpart as Part
Set Hpart = CATIA.Documents.Item("H.CATPart").Part

Dim Hpt As point
Set Hpt =  HPart.Bodies.Item("PartBody").hybridShapes.Item("H") 	

dim coords(1) as double
'Hpt.GetCoordinates coords
'Msgbox coords(0)
'MsgBox coords(1)

Dim HRef As Reference
Set HRef = Hpart.CreateReferenceFromObject(Hpt)

Dim Cpart as Part
Set Cpart =  CATIA.Documents.Item("CPart.CATPart").Part



Dim HSFactory As Factory
Set HSFactory = Cpart.HybridShapeFactory

Dim Cpt As HybridShapePointCoord
Set Cpt = HSFactory.AddNewPointCoordwithreference(60. ,60. ,60., HRef)

CPart.Bodies.Item("PartBody").InsertHybridShape Cpt

Cpart.InWorkObject = Cpt

Cpart.Update 

End Sub

Update:
I've tried the toolbox in Hpart
Dim HSFactory As Factory
Set HSFactory = Hpart.HybridShapeFactory

The failing function now is the one for insertion.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor