Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-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
Jan 8, 2014
55
0
0
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!
 
Replies continue below

Recommended for you

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