Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Polyline lenght macro

Status
Not open for further replies.

Gilgamesh99

Automotive
Jun 11, 2013
45
MX
Hi:

Im trying to get the length of a polyline in order to export that number to a drawing. I've search thru several pages and forums (including this one) but there's no similar code, even the online documentation!. I think thats achieved with a command called getmeasurable or something like that. Just to clarify, I need to extract the lenght of the polyline within the code whithout using the selection command.

Thank you in advance for your help.
 
Replies continue below

Recommended for you

@Gilgamesh99
You are right about having to use GetMeasurable. Use the following code. Here's an example of what it will look like. We might need to modify the code for your specific purpose (i.e. instead of showing the length in a message box we can export it to a drawing).

Code:
Sub CATMain()

'---- Begin resolution script for object : Polyline.1

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapePolyline1 As HybridShapePolyline
Set hybridShapePolyline1 = hybridShapes1.Item("Polyline.1")

'---- End resolution script

Dim referenceObject As Reference
Set referenceObject = hybridShapePolyline1
Dim TheSPAWorkbench As Workbench
Set TheSPAWorkbench = CATIA.ActiveDocument.GetWorkbench("SPAWorkbench")
Dim TheMeasurable As Measurable
Set TheMeasurable = TheSPAWorkbench.GetMeasurable(referenceObject)

MsgBox TheMeasurable.Length

End Sub

Regards,
Drew Mumaw
 
THANK YOU VERY MUCH!!!!

This information is extremely valuable. You're the man!. By the way, there are people in these forum who knows a lot about catia automation, and Im wondering, where exactly did you learn all of this stuff, what kind of career or courses do I have to take in order to acquire the same knowledge?
 
it takes times to learn, you go one step at a time... search forum, search again, and RTFM, then try to provide answer to question on the forum [bigsmile]

if you search GetMeasurable in DS online doc you should find some exemple...

try to get XYZ of a point, area of a circle, volume of a cube...then smallest distance between 2 curves, distance between 1 point and a cube along a direction... that's how you learn.

If you want to help others after that, you can add some files to the FAQ.

Eric N.
indocti discant et ament meminisse periti
 
Thanks for the advice!. I thought there were some special advanced courses to learn this stuff.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top