×
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

CATIA VBA select a planar section knowing its BREP name

CATIA VBA select a planar section knowing its BREP name

CATIA VBA select a planar section knowing its BREP name

(OP)
Hi all,

I made a macro in which one I create Planar Sections (lot of them).
As the planar section creation is not scriptable (because it needs user to click on buttons) it creates the planar sections beginning from PlanarSection.1 and then 2,3,4,5,6...
But you would know that if there were already planar sections created in the part before, the name of the new planar section created would begin according to the last planar section iteration created.
Thus the only 2 options I had to be able to accurately select the planar section I wanted (to change visproperties) were :

1)- create geo set with its own name ex : geo_set_1, copy the first planar section, paste it in the geo set created and delete it from the old geo set. (very heavy in time consumption)
2)- select all the planar sections created, get the BREP name of the first Item (or the fifth, tenth...), and select it (This would be the better solution for me)

Fact is, I don't know how to get the name of one of the planar sections item in particular...

here is the idea :

CODE --> vba

geoset = "Name_Of_The_Geo_Set_I_Have_Created_My_Planar_Sections_In"
oSelection.Search ("Name=" & geoSet) ''''''''''''''''''''' I select the geoset in which one are the planar sections I'm interested in
oSelection.Search "CATPrtSearch.SkinFeature,sel" ''''''''' I search for the planar sections Item in the geoset previously selected and select them           
For i = 1 To oSelection.Count '''''''''''''''''''''''''''' I make a loop to get the name and save them in an array I created before
    Set brepresentation = oSelection.Item(i).Value ''''''' I get the Value of the item I want to save its name next in the array and be able to get its name after
    brepresentationname = brepresentation.Name ''''''''''' I get the Name of the selection item (i) (gives me "CLDGeom.174" for exemple I guess it is its BREP name)
    MsgBox brepresentationname ''''''''''''''''''''''''''' This is to check the Name of the selected Item
    arr(i) = CStr(brepresentationname) ''''''''''''''''''' This is to save the name in the array
Next 

Now what I want is to select the planar section Item I'm interested in to change its visual properties thanks to the name saved in the array I filled previously.
Does anyone knows How to do it?
Truth is I have been looking for a while in internet but never found this thread in any forum...

Thank you.

RE: CATIA VBA select a planar section knowing its BREP name

Hello,

Why don't you store them in a collection (as objects) instead of their names (as strings) in an array?
1. initialize a collection
2. myCollection.add oSelection.Item(i).Value
3. later, parse the collection and load each object into activedocument.selection and change its properties.

Hope it helps,
Calin

RE: CATIA VBA select a planar section knowing its BREP name

(OP)
Thanks a lot,
I will try

RE: CATIA VBA select a planar section knowing its BREP name

(OP)
Ok It seemed to work but at the oSelection.Add myCollection.Item(i) CATIA selects the geometrical set in which one are the planar sections but not the planar sections....
any advice ?

CODE --> vba

Dim myCollection As New Collection
oSelection.Search ("Name=" & geoSet)
oSelection.Search "CATPrtSearch.SkinFeature,sel"
numSection = oSelection.Count
For i = 1 To numSection 
    myCollection.Add oSelection.Item(i).Value
Next

For i = 1 To numSection
    oSelection.Clear       
    oSelection.Add myCollection.Item(i)
    oSelection.VisProperties.SetShow 0
    oSelection.Clear
Next 

Best regards

RE: CATIA VBA select a planar section knowing its BREP name

(OP)
up?

RE: CATIA VBA select a planar section knowing its BREP name

(OP)
As mentionned earlier, I'm trying to select the planar sections, not the geometrical sets.
Is there an issue with the collection I created ?

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