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!

CATIA VBA select a planar section knowing its BREP name

Status
Not open for further replies.

jissididi

Automotive
Mar 17, 2015
46
FR
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:
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.
 
Replies continue below

Recommended for you

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
 
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:
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
 
As mentionned earlier, I'm trying to select the planar sections, not the geometrical sets.
Is there an issue with the collection I created ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top