vbacatia

How to know which CATIA PART is in the current edit mode


I am working in CATIA Product / assembly. Following is structure- Component Structure

When current active part (not instance). Like one I have shown in red block in above image.

I found similar question at Similar post, but solution given works when instance is activated, not part.

I want part to create/edit entities from it.


Solution

  • You could change the search string to search for a part:

       'Search for part in active node
       oSel.Search "CATPrtSearch.PartFeature,in"
    
       If oSel.Count2 <> 0 then
          'first selected part is the active node
          Set oPart = oSel.Item2(1).Value
          Set oActiveProduct = oSel.Item2(1).LeafProduct
          Set oPartDoc = oActiveProduct.ReferenceProduct.Parent
          MsgBox "Active Instance of a Part: " & oActiveProduct.Name & Chr(13) & "Type: " & TypeName(oDoc) & Chr(13) & "FileName: " & oDoc.Fullname, 0, "Active node"
       End If
    

    Also consider to check the active workbench using CATIA.GetWorkbenchId() first.