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.
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
Can you do it manually? Why do you need a macro? Is worth to develop something like this? Did you tried to record a macro just doing manually what you want? V5? V6? CATScript? Catvba? OS? PDM/PLM? Or file based?
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Macro that repeats for each instance in pattern
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
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: Macro that repeats for each instance in pattern
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 NextSkip,
Just traded in my OLD subtlety...
for a NUance!
RE: Macro that repeats for each instance in pattern
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.
indocti discant et ament meminisse periti
RE: Macro that repeats for each instance in pattern
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
indocti discant et ament meminisse periti
RE: Macro that repeats for each instance in pattern
Thanks