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

Status
Not open for further replies.

SurfaceWork

Automotive
Mar 12, 2017
6
SE
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.
 
Replies continue below

Recommended for you

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.
 
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.


In general...
Code:
'
   Dim pt As Object

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

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
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:
Dim rectPattern1 As RectPattern
Set rectPattern1 = hybridShapes1.Item("RectPattern.1")

Dim reference1 As Reference
Set reference1 = part1.CreateReferenceFromBRepName("BorderFVertex:(BEdge:(Brp:(RectPattern.1;[b][highlight #FCE94F]5-5[/highlight][/b]:(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
 
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?
 
read the post again

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

Part and Inventory Search

Sponsor

Back
Top