×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Polyline lenght macro

Polyline lenght macro

Polyline lenght macro

(OP)
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.

RE: Polyline lenght macro

@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 --> vba

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
http://www.drewmumaw.com/
http://www.textsketcher.com/

RE: Polyline lenght macro

(OP)
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?

RE: Polyline lenght macro

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

RE: Polyline lenght macro

(OP)
Thanks for the advice!. I thought there were some special advanced courses to learn this stuff.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources