×
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 that repeats for each instance in pattern

Macro that repeats for each instance in pattern

Macro that repeats for each instance in pattern

(OP)
Hi,

I'm trying to build a macro, but I am struggling to get started.

I want the user to be prompted to select two things:
1) Select a pattern
2) Select a surface

Next I want a For-loop that will go through the pattern.
The pattern will be a number of points.
So, point for point I now want to project each one on the surface.

Currently I am struggling to even get a macro that will do more than display a message box.

RE: Macro that repeats for each instance in pattern

(OP)
I can do it manually, selecting one point at a time and projecting it.
It would be convenient to use a macro because I have a few thousand points.

When I record a macro for one point I will get a macro for repeatedly projecting that point.
What I need is to modify the code to allow me to select a pattern or geometrical set and cycle through the points inside it.

I'm working with V5.

RE: Macro that repeats for each instance in pattern

I know nothing about the CATIA object model, but that's a pretty important bit of information you just might want to become familiar with.

However, knowing something about object models and programming with such, I can say with some degree of probability that your pattern is an object as is your surface. And the points in that particular pattern are an object collection within your pattern.

If it were me, I'd open Excel, which has several features in the VBA Editor that can help you discover what specific objects are available to you in your code.

http://www.tek-tips.com/faqs.cfm?fid=4594

In general...

CODE

'
   Dim pt As Object

   For Each pt In YourPattermObject.Points
      'Do something with pt point
   Next 

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: Macro that repeats for each instance in pattern

if only it was that easy. Sadly it seems Pattern object does not have any property or method that will output a collection of the result.

you have to loop through each point from their BREP name:

CODE --> vba

Dim rectPattern1 As RectPattern
Set rectPattern1 = hybridShapes1.Item("RectPattern.1")

Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromBRepName("BorderFVertex:(BEdge:(Brp:(RectPattern.1;5-5:(Brp:(GSMPoint.1)));None:(Limits1:();Limits2:();+1);Cf11:());WithPermanentBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", rectPattern1) 

In the code above you see I am using the (5,5) point from the pattern.

It start at (0,0) up to (pattern.FirstDirectionRepartition.InstanceCount.Value, pattern.SecondDirectionRepartition.InstanceCount.Value)

please read V5Automation.chm to get catia object info.
You can also use Locals values while debugging, this can also help you.

The loop is basic VBA stuff.

Eric N.
indocti discant et ament meminisse periti

RE: Macro that repeats for each instance in pattern

(OP)
That should put me on the right track.
A loop over i and j, being the size of the pattern would do the trick.
Is there a way to get the size of the pattern?

RE: Macro that repeats for each instance in pattern

read the post again

Eric N.
indocti discant et ament meminisse periti

RE: Macro that repeats for each instance in pattern

(OP)
Right, I see it now, will try this.
Thanks

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