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!

Get angle

Status
Not open for further replies.

theing

New member
Mar 5, 2014
18
hi everybody, i am new in this, and i am learning,

i need to get the angles of a surface, i have the following code


Sub catmain()

Set objsel = CATIA.ActiveDocument.Selection
objsel.Clear
objsel.Search "Type=Topology.Face,all"

Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
Set Selection = partDocument1.Selection

Set ref1 = Selection.Item(1).Reference
Set spabench = partDocument1.GetWorkbench("SPAWorkbench")
Set mymeas = spabench.GetMeasurable(ref1)

On Error Resume Next
Angle = mymeas.Angle
MsgBox Angulo

End Sub

the msgbox is empty, and i dont know what am i doing wrong,
i hope anyone can help me out with this,

Thank you for taking the time reading this.
 
Replies continue below

Recommended for you

Hi,

You are checking in MsgBox for Angulo and this is not evaluated in the code....probably should be Angle? And why are you searching for all faces when you need first one in selection (Selection.Item(1)) ? Is easier to tell the user to pick the face and use user selection...search the forum for some examples and also check the v5automation.chm file.

Regards
Fernando

 
hi ferdo, thank you so much for taking the time reading my issue,

i already change the msgbox and still giving me nothing,

and i search for all the faces because i thought that the faces needed to be count previously,

 
never mind i just did it, the thing is that is no giving me anything with surface, i dont know is that the way it should be, but it is giving me an angle with an edge, so i guess i will have to evaluate the edges, here is the code i have:

Sub catmain()

Set objsel = CATIA.ActiveDocument.Selection
Set partDocument1 = CATIA.ActiveDocument

Set ref1 = objsel.Item(1).Reference
Set spabench = partDocument1.GetWorkbench("SPAWorkbench")
Set mymeas = spabench.GetMeasurable(ref1)

On Error Resume Next
Angle = mymeas.Angle
MsgBox Angle

End Sub
 
Of course

Code:
Sub CATMain()

Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = productDocument1.Selection
selection1.Clear

Dim InputObjectType(0), Status1
InputObjectType(0)="Edge"
Status1=selection1.SelectElement2(InputObjectType,"Select 1st Edge",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub

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

Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = productDocument1.GetWorkbench("SPAWorkbench")

Dim TheMeasureable
Set TheMeasureable = TheSPAWorkbench.GetMeasurable(reference1)

selection1.Clear
Status1=selection1.SelectElement2(InputObjectType,"Select 2nd Edge",false)
If Status1 = "Cancel" Then selection1.Clear: Exit Sub

Dim reference2 As Reference
Set reference2 = selection1.Item(1).Reference

msgbox TheMeasureable.GetAngleBetween(reference2)

End Sub

Regards
Fernando

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor