Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

origin

Status
Not open for further replies.

mayrou

Electrical
Joined
Jan 8, 2014
Messages
55
Location
TN
hello everybody!

I tried to create a macro that give me the origin of a selected cercle!

Code:
MsgBox "selectionnez un trou"
Dim InputObjectType(0), Status1
InputObjectType(0)="Hole"
Status1=selection1.SelectElement2(InputObjectType,"Select un trou",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub

Dim reference1 As Reference
Set oHole = selection1.Item(1).value

'************************Origine du trou********************************

'get the origin of the hole using the variant object
Dim origin(2)
oHole.GetOrigin (origin)

Msgbox "Origin = " & origin(0) & ", " & origin(1) & ", " & origin(2)
'******************************************************************
i tried this one but it gives wrong values!
 
The Hole must be selected..
Code:
Sub origin()

Set oDocument = CATIA.ActiveDocument
Set oHole = oDocument.Selection.FindObject("CATIAHole")

Dim origin(2)
oHole.GetOrigin origin

MsgBox "Origin = " & origin(0) / 25.4 & ", " & origin(1) / 25.4 & ", " & origin(2) / 25.4

End Sub
 
thank you AlexLozoya for you help! :)
the hole is already selected! but what "25.4" refers to?
after all, the values still wrong :(
 
Alex assumed you are using inches while CATIa script only use mm, so 25.4 will convert mm to inches.

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top