×
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

Any Help Deeply appreciated

Any Help Deeply appreciated

Any Help Deeply appreciated

(OP)
Hello Everyone
I am working as a electrical design engineer. I want to create a macro in VBA to Clean (Hide geometric set, Set Layer for Bodies and change the colour of rib) electrical bundle.
I have attached image of the Product structure.
My Aim is
1. Walk down on the Tree
2. Select the part (not by User) but through coding condition for selecting part is having “BS” in the naming and then do the cleaning.
3. I have three Geometric bundle and all the geometric bundle having one “BS” part. Different “BS” could have different Colour.

I am getting the Part with “BS” after that I am not able to select that Part through Code…………..

Please see the attached image of Product structure
Wright now I am running separately all the macros, like for changing colour one macro, hiding geometric set one , setting layer one and that to with pre selection of each BS separately.
Please see the code below

--------------------------------------------------------------
Option Explicit
Sub CATMain()
'Get the Current Catia Assembly
Dim oProdDoc As ProductDocument
Set oProdDoc = CATIA.ActiveDocument

Dim oRootProd As Product
Set oRootProd = oProdDoc.Product


'Begin scrool Down the Specification tree

Call WalkDownTree(oRootProd)

End Sub

'WalkDownTree is a recursive function to scroll down the specification tree and output names of each item

Sub WalkDownTree(oInproduct As Product)

Dim oInstances As Products
Set oInstances = oInproduct.Products

'-----------No Instances found then this is a Catpart--------------------

If oInstances.Count = 0 Then
MsgBox "This is a CatPart With Part Number " & oInproduct.PartNumber
If Mid(oInproduct.PartNumber, 17, 2) = "BS" Then
Dim String1 As String
String1 = oInproduct.PartNumber
MsgBox String1
Dim EditBundle As Product
Set EditBundle = CATIA.Documents.Item(String1)
Dim objSelection As Selection
MsgBox "This is a MultiBranchable With Part Number " & oInproduct.PartNumber
End If
Exit Sub
End If

'---------- Found an Instance therefore it is a CATproduct----------------

'MsgBox "This is a CATProduct With Part Number " & oInproduct.ReferenceProduct.PartNumber


Dim k As Integer

For k = 1 To oInstances.Count
Dim oInst As Product
Set oInst = oInstances.Item(k)
'Apply Design Mode
oInstances.Item(k).ApplyWorkMode DESIGN_MODE
Call WalkDownTree(oInst)
Next

End Sub

RE: Any Help Deeply appreciated

Hello!

Why don't you use the search function?

CODE --> CATScript

Sub CATMain()
set Sel = CATIA.ActiveDocument.Selection 
Sel.Search "Name=BS,all"
End Sub 

That way you may find the part with BS in it

RE: Any Help Deeply appreciated

(OP)
Hello Thanks For the Reply
I can do it if all the BS having Same Colour.
I have three Harness with three different colour.
If you check the attached image you will find............

RE: Any Help Deeply appreciated

(OP)
Hello
Still there is no reply, without any help I am not able to continue

RE: Any Help Deeply appreciated

is your recursive script working?

if so then just call your other macro with the BS part as argument at the right time.



Eric N.
indocti discant et ament meminisse periti

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