Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX-Open Automatic Solid Density Change 1

Status
Not open for further replies.

Meccanista

Aerospace
Sep 11, 2008
2
New PostMeccanista (Aerospace)
30 Jun 09 9:48
I am trying to create a journal in NX-Open – Visual Basic to automatically change the Solid Density of a given set of part files.
It seems that the following simple piece of code has no effect while it is expected to set the density of each solid body in the workpart.
I am currently working with UG NX 4, .Net Framework 1.1, Windows 2000.

' NX 4.0.4.2
' Journal created by ...
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim length As Int32 = 0
Dim displayPart As Part = theSession.Parts.Display

theSession.ListingWindow.Open

For Each obj As Body In theSession.Parts.Work.Bodies
If TypeOf obj Is Body Then
obj.Density = 1000
length = length + 1
theSession.ListingWindow.WriteLine(length & ": " & Ctype(obj.Density, String))
End If
Next

End Sub
End Module
 
Replies continue below

Recommended for you

There seems to be problem with setting the property. The following works.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim workPart As Part = theSession.Parts.Work
Dim length As Int32 = 0
Dim displayPart As Part = theSession.Parts.Display

theSession.ListingWindow.Open

For Each obj As Body In theSession.Parts.Work.Bodies
If TypeOf obj Is Body Then

ufs.Modl.SetBodyDensity(obj.Tag,UFModl.DensityUnits.GramsCentimeters, 1000.0)
length = length + 1

theSession.ListingWindow.WriteLine(length & ": " & Ctype(obj.Density, String))
End If
Next

End Sub
End Module

Suresh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor