cancel
Showing results for 
Search instead for 
Did you mean: 

Open API interface to Weight Management (Setting Reference Set)

Valued Contributor
Valued Contributor

My piecemealing of code from various sources is failing me given I have no idea what I'm doing Smiley Happy

 

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.

 

Thanks!

 

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

 

1 REPLY

Re: Open API interface to Weight Management (Setting Reference Set)

Valued Contributor
Valued Contributor

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