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.
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
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
RE: Jornal Programming Newbie
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
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
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
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
CODE
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
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
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
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
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
CODE
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