Submitted by dmenz on Wed, 06/04/2014 - 11:04
Forums:
Hello everyone,
I'm trying to modify the items shown in my Part List.
I have one Assembly and two drawing sheets. Each drawing sheet should have different Part List (the entire assembly components are shown on both), according to the "phase" of the assembly.
I'm using the ufs.Plist class, I have managed to use some of the functions, but I can't erase the components that I don't need.
Any help it's welcome.
Thanks,
David.
re: modify parts list
What version of NX are you using?
Also, by "erase the components that I don't need", I assume you mean delete the line in the parts list, not delete the component itself - is this correct?
re: modify parts list
Thanks for your time.
I'm using NX 8.5 and yes, delete the line in the part list.
Thanks again
Automative
re: modify parts list
Have you tried the Plist.RemoveObject method? I worked up a small example that seems to work (not thoroughly tested). The code will remove the selected component from the first parts list found.
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
If IsNothing(theSession.Parts.Work) Then
'active part required
Return
End If
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Const undoMarkName As String = "Remove component from parts list"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
Dim myPlistTags() As Tag
Dim numPlists As Integer
theUfSession.Plist.AskTags(myPlistTags, numPlists)
'lw.WriteLine(numPlists.ToString & " Parts list(s) found")
Dim myComponent As Assemblies.Component
If SelectComponent("Select Component", myComponent) = Selection.Response.Cancel Then
Return
End If
theUfSession.Plist.RemoveObject(myPlistTags(0), True, myComponent.Tag)
theUfSession.Plist.Update(myPlistTags(0))
lw.Close()
End Sub
Function SelectComponent(ByVal prompt As String, ByRef selObj As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select a Component"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_component_type
.Subtype = UFConstants.UF_all_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
End Module
re: modify part list
Thank you so much.
I'll use your code as guide. My app needs to be completely automated, so I'll just change the way the component its selected.
Thanks again master.
Automative