×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX-Open Automatic Solid Density Change

NX-Open Automatic Solid Density Change

NX-Open Automatic Solid Density Change

(OP)
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

RE: NX-Open Automatic Solid Density Change

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
www.technisites.com.au

RE: NX-Open Automatic Solid Density Change

(OP)
Very good, it works!
Thanks a lot.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources