×
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

renaming Branchables in the wiring module

renaming Branchables in the wiring module

renaming Branchables in the wiring module

(OP)
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






RE: renaming Branchables in the wiring module

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: renaming Branchables in the wiring module

(OP)
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

RE: renaming Branchables in the wiring module

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

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