Continue to Site

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!

renaming Branchables in the wiring module

Status
Not open for further replies.

jewely

Automotive
Dec 12, 2012
11
US
i need to rename/number all the Branchables in my wire harness. i have a macro that not only FINDS them all, but will select them as well. the problem is that if i echo/query what i have selected with:

msgbox("branch name = " & oSel.item(i).Value.Name)

i do not get what i expect. it doesn't tell me the name/number of the branchable that i selected, instead, the program returns the instance name of the GRANDPARENT of the selected item. when the code runs, that's what gets changed, the instance name of the grandparent. why? i would understand if i had said:

msgbox("branch name = " & oSel.item(i).Value.Parent.Name) or msgbox("branch name = " & oSel.item(i).Value.Parent.Parent.Name)

but i am trying to change the item i SELECTED! there is some talk that even though i can do it manually by going in to the Properties form, it cannot be done with a macro. this makes no sense. also, in the object browser, there is no listing for 'Branchable'. no amount of rewriting will get me the result i need. HELP!

jewely
see pic






 
Replies continue below

Recommended for you

Hi,

jewely, it will be great if you will post a sample/similar file, if someone want to try a code should have something to test....

I would do something like this (pseudo-code)

selection1.Search "........"
'A loop to go thru each selected item and change it's name.
intNbSelected = selection1.Count2
If intNbSelected > 0 Then
For intIndex = 1 to intNbSelected
selection1.Item2(intIndex).Value.Name = "Branchable." &intIndex
Next
End If

There is something similar but for constrains in my CATIA Portable Script Center.



Regards
Fernando

 
PARTIAL CODE:

SIMPLE AND TO THE POINT:

CATIA.DisplayFileAlerts = False
CATIA.RefreshDisplay = False

Dim oSel As Selection
Dim oSelEl As Selection
Dim i as Integer
Dim BCount as Integer

Set oSel = CATIA.ActiveDocument.Selection
Set oSelEl = CATIA.ActiveDocument.Selection

oSel.Search("type = Branchable, all")
BCount = oSel.count
msgbox ("Number of Branchables found = " & BCount)

For i = 1 to BCount
Msgbox(i & " before name = " & oSel.Item(i).Value.Name)
oSelEl = oSel.Item(i).Value.Name
Msgbox(i & " after name = " & oSel.Item(i).value.Name)
Next
 
hi,

Try to get the reference product of the branches selected.
this way you can get the parent of the selected product. and rename the parameter PartNumber.
This will change the PartName as you are asking.

I cannot recall off hand though, but code might be like this
So add these in your for loop :
Set oProdToRename = Selectio,Item(I).Value.ReferenceProduct
oProdToRename.PartNumber = "XXXXXX"

Below is an example from a product with 3 parts :
Set productDocument1 = CATIA.ActiveDocument
Set product1 = productDocument1.Product
Set products1 = product1.Products
Set product2 = products1.Item(2).Referenceproduct
MsgBox product2.Name
product2.PartNumber = "SSSSSS"

Hope this works for you.

Regards,
Maddy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top