Macro to Fill Multiple Polylines
Macro to Fill Multiple Polylines
(OP)
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.
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.
RE: Macro to Fill Multiple Polylines
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.
indocti discant et ament meminisse periti
RE: Macro to Fill Multiple Polylines
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
RE: Macro to Fill Multiple Polylines
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:
so if you go like this:
CODE --> vba
indocti discant et ament meminisse periti