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.
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
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 SubRegards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Polyline lenght macro
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
Read my last 3 posts on this Eng-Tips thread.
Regards,
Drew Mumaw
http://www.drewmumaw.com/
http://www.textsketcher.com/
RE: Polyline lenght macro
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.
indocti discant et ament meminisse periti
RE: Polyline lenght macro