×
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

Cheking a model for an attached drawing using VB

Cheking a model for an attached drawing using VB

Cheking a model for an attached drawing using VB

(OP)
Does anyone know a command that checks if a the current model has a drawing sheet? I have been looking for a couple days so far, but have not found any luck..

Thanks for the help!

Eric Roe
Electro-Mechanical Engineer
Airfloat LLC

RE: Cheking a model for an attached drawing using VB

Each part has a drawing sheet collection that you can inspect to see if there are drawing sheets and if so, how many.

CODE

Option Strict Off Imports System Imports NXOpen Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim workpart As Part = theSession.Parts.Work Dim dwgSheets() As Drawings.DrawingSheet = workpart.DrawingSheets.ToArray Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim i As Integer = 0 For Each dwg As Drawings.DrawingSheet In dwgSheets lw.WriteLine("Sheet name: " & dwg.Name) lw.WriteLine("Length: " & dwg.Length) lw.WriteLine("Height: " & dwg.Height) lw.WriteLine("") Next lw.WriteLine("There are " & dwgSheets.Length & " sheet(s) in the file") lw.Close() End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination End Function End Module

www.nxjournaling.com

RE: Cheking a model for an attached drawing using VB

(OP)
I can think of a couple ways to do this, but my problem lies in finding the appropriate VB commands to execute (this is usually my problem when it comes to writing journal files in Vb).

I currently have a journal file that will set the drafting sheet to display, and then save the file in modeling. The only problem is that sometimes there is a file that does not have a drawing sheet attached, so it throws an error.

If there was a command to check if drawing sheets exist, then I could use it in an if statement.

Or if there is a command that returns the number of drawing sheets in the file, then I can use an if statement to check if the command returns 'zero'...

These are my thoughts, which boils down to knowing the right command.

I still do not quite understand how people find these commands? I have not found a very easy way to search for a certain command.. (other than posting a thread on here, which has always worked great). If it is something simple, I usually record a journal, then cut and past the commands from the "auto code" into a new program in order to manipulate it to do what I want it to.

Can someone share how they learn so many commands? Or is it something that just comes with time, and experience?

Thanks again, and sorry for the double post with multiple questions...

Eric Roe
Electro-Mechanical Engineer
Airfloat LLC

RE: Cheking a model for an attached drawing using VB

(OP)
cowski,

Thanks for the help! Program works great.

Eric Roe
Electro-Mechanical Engineer
Airfloat LLC

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