CATIA VBA renaming one item of a selection
CATIA VBA renaming one item of a selection
(OP)
Hello all,
I have an issue in a macro i'm making
I have various geometrical set all of them for different uses
in those Geometrical sets, I created some planar sections and then I want to rename them all "Planar Section.1" "Planar Section.2" "Planar Section.3"...
to create the planar sections, I create them all at the same time using the mesh and all the different planes and creating them by plane.
problem is that if there has been a section created previously, my first created section won't have the name "Planar Section.1"
So i created a selection of all the planar sections in the geometrical set corresponding, used the selction.item(i) to make a for loop and rename them all
but it doesn't work...
here is my idea
Anyone has a working idea ?
Thanks
jissididi
I have an issue in a macro i'm making
I have various geometrical set all of them for different uses
in those Geometrical sets, I created some planar sections and then I want to rename them all "Planar Section.1" "Planar Section.2" "Planar Section.3"...
to create the planar sections, I create them all at the same time using the mesh and all the different planes and creating them by plane.
problem is that if there has been a section created previously, my first created section won't have the name "Planar Section.1"
So i created a selection of all the planar sections in the geometrical set corresponding, used the selction.item(i) to make a for loop and rename them all
but it doesn't work...
here is my idea
CODE --> Next
oSelection.Clear
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Add part1.FindObjectByName("AUTO_MODE_GEOMETRICAL_SET")
oSelection.Search "'Part Design'.'Wireframe & Surface Feature';sel"
iterationAutoMode = oSelection.Count
For i = 1 To iterationAutoMode
oSelection.Item(i).Value.Name = "AUTO_MODE_GEOMETRICAL_SET_SECTION_" & i
Next Anyone has a working idea ?
Thanks
jissididi





RE: CATIA VBA renaming one item of a selection
I believe it does what you want.
CODE --> CatVBA
Sub CATMain() Dim partDocument1 As PartDocument Set partDocument1 = CATIA.ActiveDocument Set oSelection = CATIA.ActiveDocument.Selection oSelection.Clear Dim part1 As Part Set part1 = partDocument1.Part oSelection.Search "(Name=AUTO_MODE_GEOMETRICAL_SET* & (CATPrtSearch.OpenBodyFeature)) ,all" iterationAutoMode = oSelection.Count For i = 1 To iterationAutoMode oSelection.Item(i).Value.Name = "AUTO_MODE_GEOMETRICAL_SET_SECTION_" & i Next End SubTiago Figueiredo
Tooling Engineer
RE: CATIA VBA renaming one item of a selection
Thanks for the post but it was not the name of the geometrical set i wanted to change but the name of the sections which are inside the geometrical set.
as i have for example 10 section in the first geometrical set and 5 in the second geometrical set, i want to change the name of each section accordingly to the geometrical set they are
Thanks again.
RE: CATIA VBA renaming one item of a selection
Tiago Figueiredo
Tooling Engineer
RE: CATIA VBA renaming one item of a selection
As you can see, in the geometrical set named "manual angular geometrical set", the planar sections created begin by 16, I want it to be 1, 2,3 as for the geometrical set "auto mode"
RE: CATIA VBA renaming one item of a selection
Tiago Figueiredo
Tooling Engineer
RE: CATIA VBA renaming one item of a selection
in fact in my macro i can create first the manual ones or first the auto mode ones,
so that It can happen that sections from the auto set or from the manual set are created with a bad name
RE: CATIA VBA renaming one item of a selection
1-Select the "Auto" geometrical set
2-Search all planar sections inside it
3-Rename all planar sections
4- the same for the "Manual"
Tiago Figueiredo
Tooling Engineer
RE: CATIA VBA renaming one item of a selection
CODE --> CATScript
Language="VBSCRIPT" Sub CATMain() Dim partDocument1 As Document Set partDocument1 = CATIA.ActiveDocument Dim selection1 As Selection Set selection1 = partDocument1.Selection selection1.Search "Name=*GS_1*,all" Dim oselection1 As Selection Set oselection1 = partDocument1.Selection oselection1.Search "CATPrtSearch.Plane,sel" iterationAutoMode = oselection1.Count For i = 1 To iterationAutoMode oSelection1.Item(i).Value.Name = "GS_1_Planar_Section_" & i Next Dim selection11 As Selection Set selection11 = partDocument1.Selection selection11.Search "Name=*GS_2*,all" Dim oselection11 As Selection Set oselection11 = partDocument1.Selection oselection11.Search "CATPrtSearch.Plane,sel" iterationAutoMode11 = oselection11.Count For i = 1 To iterationAutoMode11 oSelection11.Item(i).Value.Name = "GS_2_Planar_Section_" & i Next End SubRegards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU
RE: CATIA VBA renaming one item of a selection
does anyone know the search command that would allow me to select the "Planar Sections" instead of the planes ?
something like oselection11.Search "CATPrtSearch.Planar Sections,sel"
Thanks
(I have tried another way of getting the elements i wanted selected by selecting all the elements of the same type and removing the instances i didn't want
But when I finally have the element I want selected, I get an error during the oSelection.Name method and I don't know why)
RE: CATIA VBA renaming one item of a selection
RE: CATIA VBA renaming one item of a selection
Try to record a macro where you find those, with the find command. On type select "from element" and pick one of those planar sections.
Tiago Figueiredo
Tooling Engineer
RE: CATIA VBA renaming one item of a selection
Here is what I found
I tell you if it solved my problem
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim selection1 As Selection
Set selection1 = partDocument1.Selection
selection1.Search "CATPrtSearch.SkinFeature,all"
End Sub
RE: CATIA VBA renaming one item of a selection
So I tried it but unfortunately, the method oSelection.Item(i).Value.Name give me an error....
I don't know How to manage this anymore
iterationAutoMode = 0
oSelection.Clear
Set oSelection = CATIA.ActiveDocument.Selection
oSelection.Search ("Name=AUTO_MODE_GEOMETRICAL_SET")
oSelection.Search "CATPrtSearch.SkinFeature,sel"
iterationAutoMode = oSelection.Count
For i = 1 To iterationAutoMode
oSelection.Item(i).Value.Name = "MANUAL_ANGULAR_GEOMETRICAL_SET_SECTION_" & i
Next
RE: CATIA VBA renaming one item of a selection
I just tried to run my code selecting the planes instead of the planar sections and it works perfect,
I just don't understand why it does not work for the Planar Sections....
RE: CATIA VBA renaming one item of a selection
Tiago Figueiredo
Tooling Engineer
RE: CATIA VBA renaming one item of a selection
so the selection works fine but the .Name method does not with the planar sections
RE: CATIA VBA renaming one item of a selection
set NewName=selection1.item(i).value
NewName.Name="MANUAL_ANGULAR_GEOMETRICAL_SET_SECTION_" & i
Tiago Figueiredo
Tooling Engineer
RE: CATIA VBA renaming one item of a selection
tells me that NewName does not support the .Name property
RE: CATIA VBA renaming one item of a selection
Regards
Fernando
https://picasaweb.google.com/102257836106335725208 - Romania
https://picasaweb.google.com/103462806772634246699... - EU