×
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

Jornal Programming Newbie

Jornal Programming Newbie

Jornal Programming Newbie

(OP)
First we don't yet have CAST, it is in process of being purchased/installed.  However I still have work that needs completing.  We are setting UG NX7.5 up for what we hope in the future will be many users, I have been through many posts both here and on the Siemens web site and find I am lacking a lot of basic knowledge for a lot of this.  

I am looking at the Sample Title block creation and need help deciphering.  I like that it prompts the user for information but I would rather it applies those values to attributes, such as DB_PART_DESC or DB_PART_REV, or even a basic value I can have a note reference to fill in the previously created title block, as well as creating them in a part that hasn't had any set yet.  

Rather than do this/ do that, can someone give me a place to get the basics I need.  At least until CAST arrives and I can go through their information where I can only pray the information I need can be found.

RE: Jornal Programming Newbie

I would not waste a lot of time on this if you're planning on moving to NX 8.0 anytime soon.

NX 8.0 introduces a new set of functions for defining and using standard drawing boarders and title blocks which can include a combination of both automatic and system-prompted manual entries which will be placed in their proper place on your drawings.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
http://www.siemens.com/plm
UG/NX Museum:   http://www.plmworld.org/p/cm/ld/fid=209

To an Engineer, the glass is twice as big as it needs to be.
 

RE: Jornal Programming Newbie

(OP)
As the company only JUST got NX7.5 I don't think there will be an upgrade anytime soon.

RE: Jornal Programming Newbie

How familiar are you with NX?
From your question, it appears that you are setting up the environment for a new install of NX. If so, you may want to spend some time setting up your preferences/standards and get familiar with what NX offers out of the box then look at what journals/custom code can do for you. The title block program you mention is a cool little example of a journal application, but it is not required to set up title blocks, there is some other useful stuff you can do by pulling attributes from files and filling in text automatically without using journals.

RE: Jornal Programming Newbie

(OP)
I've used NX extensively in many forms and have a really good idea what it can do.  That being said I have never had to actually set up the environments.  It is true I could just import a part containing the Title block every time, but the company is looking at massive growth and I need to have an environment set up complete with standard drawing requirements as well as a working title block that future employees will be able to quickly use without altering it.

I am also using this program as a stepping stone, as I understand title blocks extremely well and figure by the end of this program I can start the more difficult process of making a program to bring in a spline using data points from a spline, putting points on the spline using preset expressions and putting datum planes on these points in the correct direction.  A process needed with nearly every model which can be tedious and time consuming, with up to 30 points per spline.

RE: Jornal Programming Newbie

Good to hear.

So for this first journal, you want to check for a specific attribute and retrieve the value, if the attribute does not exist add it with a default value? Do you use the master model method?

RE: Jornal Programming Newbie

(OP)
I don't think I'm using master model.  Most of this was set up for me when I've worked before.

What I have so far, activate journal receive a box to manually enter values, these values are set to attributes, then imports a preset border and title block file which retrieves attributes for title block information.

So far so good.  I don't like the fact that the date is automatically updating every time the journal is run, which means to update the sheet due to later revision requiring sheet size change will have to be a different macro.  Plus adding revision notes later is a bit of a pain.

This is great for new drawings but not so great for revisions.  Learning a lot though, but it is taking to long to dummy my way through which is why I am asking for a site for basic UG commands in VB.  For instance, a way to take the information from a previously set attribute and set it to a variable in the program in order to reference it, such as in a case where you have the sheet being revised and you want the current value of the attribute to show in the drop box when it comes up for a sheet change or what not.
 

RE: Jornal Programming Newbie

Here is a code snippet from a journal I wrote a while back, it check to see if there is an attribute named JobNumber. If the value is blank or the attribute doesn't exist it will prompt for a value to be assigned.

CODE

    Try
        strJobNumber = workPart.GetStringAttribute("JobNumber")
        'the attribute exists, assign the value to a variable
        strJobNumber = Trim(strJobNumber)
        Do Until isnumeric(strJobNumber)
            strJobNumber = InputBox("Enter Job Number", "Job Number", " ")
            if strJobNumber = "" then
                'null string means cancel was pressed, exit journal
                exit sub
            end if
        Loop
        strJobNumber = Trim(strJobNumber)
        workPart.SetAttribute("JobNumber", strJobNumber)
    Catch ex As Exception
        'the attribute does not exist, prompt for a value and assign the title/value to the work part
        strJobNumber = Trim(strJobNumber)
        Do Until isnumeric(strJobNumber)
            strJobNumber = InputBox("Enter Job Number", "Job Number", " ")
            if strJobNumber = "" then
                'null string means cancel was pressed, exit journal
                exit sub
            end if
        Loop
        strJobNumber = Trim(strJobNumber)
        workPart.SetAttribute("JobNumber", strJobNumber)
    end try

The code isn't optimized, there is some repetition in the try and catch blocks, but I hope it helps you out.

RE: Jornal Programming Newbie

Master model is the term for when the model file and drawing file are separate. You add the model as a component to a new file and use that new file as the drawing.

When you start retrieving/adding attributes, you'll need to know if you are adding them to the work part, the component, or the component part. All of them have their uses depending on what you need to accomplish.

RE: Jornal Programming Newbie

(OP)
The program is very useful, and I appreciate it, but I'd rather have some place I can go to answer questions like that rather than having to ask them every time they come up.

As for Master Models, currently we don't use a master, but they are looking into installing Team Center and that may change, but probably not.  

RE: Jornal Programming Newbie

(OP)
Alright cowski I need more help, here is the code area:

If openFileDialog1.ShowDialog() = DialogResult.OK Then
                Dim session As Session = Session.GetSession()
                Dim sr As StreamReader = new StreamReader(openFileDialog1.FileName)
                Dim line As String
        Dim realScaleNum As Integer
        Dim realScaleDen As Integer

        realScaleNum = workPart.GetStringAttribute("SH_SHEET_SCALE_NUMERATOR")
                realScaleDen = workPart.GetStringAttribute("SH_SHEET_SCALE_DENOMINATOR")

I am trying to bring in the scale data, I have tried, GetRealAttribute, GetIntegerAttribute and I keep getting an error cannot find attribute.

What am I missing?

Is it the workpart portion of the callout?  Is there something specific to the sheet?

RE: Jornal Programming Newbie

(OP)
After spending more than an hour on the phone with UG Support we found that the documentation included with each UG license was missing from my install.  They were able to provide me with the necessary information to install and point me to where such commands can be found.

From UG I went to Help -> NX Help

This pulled up a web browser with the help documentation, here I went to

automation -> NX Open -> Open for .NET

This asked to download a file, which I did.  This opens to an entire textbooks worth of info, but I was able to use the index option to search, use * to make sure it doesn't separate words needing to stay together.  *getscale* for instance insures it looks for get scale and not entries with "get" and "scale" in them.

Hope this helps other people  

RE: Jornal Programming Newbie

Here's some code to return the scale of the sheets in a drawing.

CODE

Option Strict Off
Imports System
Imports NXOpen

Module NXJournal

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

'***********************************************************************

Sub Main

Dim dwgs as Drawings.DrawingSheetCollection
dwgs = workPart.DrawingSheets
Dim sheet As Drawings.DrawingSheet
Dim sheetScaleNumerator as Double
Dim sheetScaleDenominator as Double
Dim i as integer
Dim lw as ListingWindow = theSession.ListingWindow

lw.Open
i = 0
For Each sheet in dwgs
    sheet.GetScale(sheetScaleNumerator, sheetScaleDenominator)
    lw.WriteLine("Sheet Name: " & sheet.name)
    lw.WriteLine("  Scale Numerator: " & sheetScaleNumerator)
    lw.WriteLine("  Scale Denominator: " & sheetScaleDenominator)
    i = i + 1
Next
    
if i = 0 then
    lw.WriteLine("This part has no drawing sheets")
end if

lw.Close

End Sub

End Module

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