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!

Macro to Fill Multiple Polylines

Status
Not open for further replies.

CatiaWiz

Mechanical
Mar 12, 2013
7
US
Hello,

I am pretty new to writing Macros. What I am looking to do is to have a macro that will scan through the geometrical set of an open Catpart and fill multiple polylines. I have a file with 20,000 polylines named POLYLINE #23, POLYLINE #24, etc. I would like the macro to create a separate fill surface for each polyline. I tried recording a macro, but it only fills the one polyline that i had selected while recording the macro. Any help would be greatly appreciated.
 
Replies continue below

Recommended for you

so you're almost there...

post your code and we'll help

What we need to do now is to get each polyline from your geoset and use it for the fill and put that in a loop.

try to use VBA as it will let you "see" or Watch object in debug mode, (see here)

So we will find the geoset/HybridBody using it's name and get wireframes/HybridShapes inside it, if the wireframe/HybridShape is a polyline, we do the fill, else we take next shape.

Try to do something like that and post your progress, we'll follow.

Eric N.
indocti discant et ament meminisse periti
 
Below is the code that I get when I record the macro to select a POLYLINE and then execute a "Fill" command.


Language="VBSCRIPT"

Sub CATMain()

Set partDocument1 = CATIA.ActiveDocument

Set part1 = partDocument1.Part

Set hybridShapeFactory1 = part1.HybridShapeFactory

Set hybridShapeFill1 = hybridShapeFactory1.AddNewFill()

Set parameters1 = part1.Parameters

Set hybridShapeCurveExplicit1 = parameters1.Item("POLYLINE #29")

Set reference1 = part1.CreateReferenceFromObject(hybridShapeCurveExplicit1)

hybridShapeFill1.AddBound reference1

hybridShapeFill1.Continuity = 1

hybridShapeFill1.TolerantMode = True

hybridShapeFill1.MaximumDeviationValue = 0.010160

Set hybridBodies1 = part1.HybridBodies

Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")

hybridBody1.AppendHybridShape hybridShapeFill1

part1.InWorkObject = hybridShapeFill1

part1.Update

Set reference2 = part1.CreateReferenceFromObject(hybridShapeFill1)

Set hybridShapeSurfaceExplicit1 = hybridShapeFactory1.AddNewSurfaceDatum(reference2)

hybridBody1.AppendHybridShape hybridShapeSurfaceExplicit1

part1.InWorkObject = hybridShapeSurfaceExplicit1

part1.Update

hybridShapeFactory1.DeleteObjectForDatum reference2

End Sub
 
if you want to see the object structure of your CATIA part I suggest you use VBA and the watch object like in the link i gave you.

That and the V5Automation.chm file from your catia install will help you progress with CATIA object understanding.

From what I see in your code, your polylines are actually isolated curves, and not CATIA V5 native polylines, that's why your code is getting the polyline from Part.Parameters

So I suggest you either get all parameters one after the other and if name is "polyline something" then you make the fill, or you do a search in Part.Parameters but as you said you have 20k polylines I would go with the first option (I had bad memories with big search in catia, it used slows the process, not sure working with 20k search is OK now)
I see in 3DX19X that explicit curves are now available from hybridbodies:
2018-12-13_19-49-03_vxq1px.png


so if you go like this:

Code:
Set parameters1 = part1.Parameters

for i = 1 to part1.Parameters.count
     Set hybridShapeCurveExplicit1 = parameters1.Item(i)
     myParamName = hybridShapeCurveExplicit1.Name

     if xxxx
        you do the fill here
     end if
next i


Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top