×
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

Macro to Fill Multiple Polylines

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.

RE: Macro to Fill Multiple Polylines

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

RE: Macro to Fill Multiple Polylines

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

RE: Macro to Fill Multiple Polylines

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:


so if you go like this:

CODE --> vba

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

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! Already a Member? Login


Resources

White Paper – Choosing the Right Spring Loaded Connector
In today’s cost-sensitive world, designers are often driven to specify the lowest cost solution for every aspect of their designs to ensure that their solution is competitively priced and their company remains profitable. However, specifying a low-cost, low-quality connector solution can result in premature failure, considerable re-work costs and damage to reputations. Download Now
eBook – Own the Lifecycle: Sustainable Business Transformation
Increasingly, product and services companies are seeking more information and control in the operational lifecycle of their products, including service and use. Better information about the operational lifecycle, and the ability to use that information, requires more than just unstructured data flowing back from products in the field. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close