My piecemealing of code from various sources is failing me given I have no idea what I'm doing
I'm trying to write a module using the Weight Management code package to Set the Reference Set to Model within the Advanced Weight Management tool for all parts loaded (Partial or Full) in the current session or within an assembly. Given I have no idea what I'm doing and I think I'm actually mixing coding languages, it's basically a total disaster.
Anyone have any pointers on how I can make this work?
Below is my feeble attempt at creating something. Don't laugh too hard.
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UI Imports NXOpen.Utilities Module NXJournal Dim theSession As Session = Session.GetSession() Sub Main () Dim allParts() As Part = theSession.Parts.ToArray() For Each thisPart As Part In allParts int UF_WEIGHT_set_part_ref_set(thisPart, "model") Next End Sub End Module
Solved! Go to Solution.
Figured it out.
Here's the code:
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module NXJournal Private Dim theSession As NXOpen.Session = NXOpen.Session.GetSession() Private Dim ufs As UFSession = UFSession.GetUFSession() Sub Main () Dim sessionParts As PartCollection = theSession.Parts Dim loadStatus As PartLoadStatus Dim parts() As NXOpen.Part = sessionParts.ToArray() For Each myPart As Part In parts theSession.Parts.SetDisplay(myPart, False, True, loadStatus) theSession.Parts.SetWork(myPart) ufs.Weight.SetPartRefSet(myPart.Tag, "MODEL") Next End Sub End Module