Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

CATIA MACRO: create a new point from a reference point

Status
Not open for further replies.

DiaeArrahmane

Automotive
Apr 4, 2024
17
0
0
FR
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

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.
Back
Top