Showing results for 
Search instead for 
Do you mean 
Reply

How to get part number of lightweight selected component ?

[ Edited ]

dim selectedComponent() = nothing ' get selected component from styler

selectedComponent = uiSelectedComponent.GetProperties.GetTaggedObjectVector("SelectedObjects")

 

dim strPn as string = ""

 

select case TypeName(selectedComponent (0))

    case "Component"

        strPn = selectedComponent (0).DisplayName

    case "FacetedBody"

       strPn = ???

end selelct

 

how to get pn of selected object (and not the assembly pn) or how to open base componet of selected component via nxOpen

 

Thanks

Avi Somech

2 REPLIES

Re: How to get part number of lightweight selected component ?

If you have a reference to a "FacetBody" type of object, it has .OwningComponent and .OwningPart properties that should give you the desired information. Alternately, you might consider restricting the selection to the Component type so that you always have a reference to the component object.

Re: How to get part number of lightweight selected component ?

[ Edited ]

I progress with the code

but  get error if associated body is not loaded (Right click --> open base component)

 

thank

Avi Somech

 

Dim SelectionMask_array(1) As NXOpen.Selection.MaskTriple
With SelectionMask_array(0)
 .Type = NXOpen.UF.UFConstants.UF_component_type 'Component assembly
End With

With SelectionMask_array(1)
 .Type = NXOpen.UF.UFConstants.UF_faceted_model_type 'Lightweight (Altrep) assembly
End With
   
Dim propsSelect As PropertyList
propsSelect = uiSelection.GetProperties()

propsSelect.SetSelectionFilter("SelectionFilter", Selection.SelectionAction.ClearAndEnableSpecific, SelectionMask_array)
propsSelect.Dispose()

Dim SelectedComponent() = Nothing
SelectedComponent = uiSelection.GetProperties.GetTaggedObjectVector("SelectedObjects")

Select Case TypeName(SelectedComponent(0))
 Case "Component"
     strPartNumberCad = SelectedComponent(0).DisplayName 'nas6703u12_bct/A
 Case "FacetedBody"


   'Extract PN from selected FacetedBody
   Dim facetedBody1 As Facet.FacetedBody = CType(SelectedComponent(0), Facet.FacetedBody)

 

   'Get error in next line if associated part is not loaded (Right click --> open base component) !!!!

  'means -  facetedBody1.IsAssociatedBodyLoaded = false !!!!

 ' How to load the Associated component ?


  Dim body1 As Body = facetedBody1.AssociatedBody
  strPartNumberCad = body1.OwningComponent.DisplayName 'nas6703u12_bct/A
End Select