Continue to Site

Welcome to 3DCADForums

Join our CAD community forums where over 25,000 users interact to solve day to day problems and share ideas. We encourage you to visit, invite you to participate and look forward to your input and opinions. Acrobat 3D, AutoCAD, Catia, Inventor, IronCAD, Creo, Pro/ENGINEER, Solid Edge, SolidWorks, and others.

Catia selection macro

hansi001

New member
Hello,

I hope you can help me.

I want to create a configurator. The user should select from an existing product, for him relevant submodels on the Userform which are loaded after confirming the OK button in a new product.

How is it possible to match the name of the submodel with a search name?

For example the part model is called "Test_0.0.01." the search term would be e.g. "Test". If the search term matches the name of the submodel, the model is selected.


Unfortunately, the function (selection1.Search) does not help me, because the previous selection will be removed in a new search. However, I would like to search for several models at the same time and select and then copy and paste them into a new product.


I recorded that with the macro recorder.


Code:
If CB_TEST = True Then
            
            Dim productDocument1 As ProductDocument
            Set productDocument1 = CATIA.ActiveDocument
            
            Dim selection1 As Selection
            Set selection1 = productDocument1.Selection
            
            'selection1.Clear
            
            Dim product1 As Product
            Set product1 = productDocument1.Product
            
            Dim products1 As Products
            Set products1 = product1.Products
            
            Dim product2 As Product
            Set product2 = products1.Item("ZSB TEST 000.0.1")
            
            Dim products2 As Products
            Set products2 = product2.Products
            
            Dim product3 As Product
            Set product3 = products2.Item("Modell-V5 TEST 000.0.1")
            
            Dim products3 As Products
            Set products3 = product3.Products
            
    
            Dim product19 As Product
            Set product19 = products3.Item("TEST 000.0.1")
        
            selection1.Add product19 
                  
        Else
      
          selection1.Remove (product19) 

        End If





Thank you very much

Hansi001
 
I wish I could help you Hansi, but I know nothing about writing CATIA macros.

But I do know a good place for you to get help: The Eng-Tips web site as a great CATIA discussion forum where there are many active and useful members that are very knowledgeable on CATIA macros and CATIA programming in general. Make sure you include the code you posted here - they really like to help people that have made an attempt at trying to solve a problem.

eng-tips.jpg
 
Last edited:

Articles From 3DCAD World

Sponsor

Back
Top