×
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

Dimensions of a drawing sheet as expressions

Dimensions of a drawing sheet as expressions

Dimensions of a drawing sheet as expressions

(OP)
Greetings all!

Is it possible to somehow reference dimensions of a drawing sheet? Maybe as system variables, or in any other way? Or are they completely sealed from any reference?

Industry creates wealth!

RE: Dimensions of a drawing sheet as expressions

What version of NX are you on ?
Do you have Teamcenter ?

RE: Dimensions of a drawing sheet as expressions

(OP)
No TC. NX8.5.

Industry creates wealth!

RE: Dimensions of a drawing sheet as expressions

If your model was created using a Sketch the sketch dimensions can be inherited onto your Drawing and then they can be referenced since Sketch dimensions are Expressions.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

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

RE: Dimensions of a drawing sheet as expressions

Do you mean you want to reference drafting dimensions on the sheet, or the dimensions of the sheet itself (width x height)?

www.nxjournaling.com

RE: Dimensions of a drawing sheet as expressions

(OP)
Hello Cowski!

Yes, I mean the dimensions of the sheet itself, width and height.

Industry creates wealth!

RE: Dimensions of a drawing sheet as expressions

(OP)
I guess it is not possible then?..

Industry creates wealth!

RE: Dimensions of a drawing sheet as expressions

Do you want to edit them or just get their values for some other purpose.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

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

RE: Dimensions of a drawing sheet as expressions

(OP)
More like get their values for some other purpose.

Industry creates wealth!

RE: Dimensions of a drawing sheet as expressions

Can you run a GRIP program?

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

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

RE: Dimensions of a drawing sheet as expressions

You can ignore the question about GRIP as my idea didn't pan out. Sorry.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

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

RE: Dimensions of a drawing sheet as expressions

Below is a journal that will create expressions based on the drawing sheet size.

Limitations:
  • The expressions are not associative to the sheet. If/when you change the sheet size, you will need to run the journal again to update the expressions.
  • The journal in its current form only looks at the first sheet in the file. If you have multiple drawing sheets of different sizes, and you want expressions for each, the journal will have to be modified.

CODE

Option Strict Off
Imports System
Imports NXOpen

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work
        Dim lw As ListingWindow = theSession.ListingWindow
        lw.Open()

        Const undoMarkName As String = "sheet size expressions"
        Dim markId1 As Session.UndoMarkId
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

        'lw.WriteLine("base unit of length: " & workPart.UnitCollection.GetBase("length").Abbreviation)

        Dim sheetLength As Double
        Dim sheetHeight As Double

        Dim unit1 As Unit = workPart.UnitCollection.GetBase("length")

        For Each tempSheet As Drawings.DrawingSheet In workPart.DrawingSheets
            If tempSheet.Units = Drawings.DrawingSheet.Unit.Inches Then
                unit1 = CType(workPart.UnitCollection.FindObject("Inch"), Unit)
            Else
                unit1 = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
            End If
            sheetLength = tempSheet.Length
            sheetHeight = tempSheet.Height
            Exit For
        Next


        Dim markId2 As Session.UndoMarkId
        markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Expression")

        Try
            'look for existing expression and update it
            Dim expression1 As Expression = CType(workPart.Expressions.FindObject("SheetHeight"), Expression)

            workPart.Expressions.EditWithUnits(expression1, unit1, sheetHeight.ToString)

            Dim nErrs1 As Integer
            nErrs1 = theSession.UpdateManager.DoUpdate(markId2)

        Catch ex As NXException

            If ex.ErrorCode = 3520016 Then
                'expression does not exist, create it
                Dim expression1 As Expression
                expression1 = workPart.Expressions.CreateWithUnits("SheetHeight=" & sheetHeight.ToString, unit1)

                Dim nErrs1 As Integer
                nErrs1 = theSession.UpdateManager.DoUpdate(markId2)

            Else
                theSession.UndoToMark(markId1, undoMarkName)
                MsgBox(ex.ErrorCode & ": " & ex.Message)

            End If

        End Try

        Dim markId3 As Session.UndoMarkId
        markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Expression")

        Try
            'look for existing expression and update it
            Dim expression1 As Expression = CType(workPart.Expressions.FindObject("SheetLength"), Expression)

            workPart.Expressions.EditWithUnits(expression1, unit1, sheetLength.ToString)

            Dim nErrs1 As Integer
            nErrs1 = theSession.UpdateManager.DoUpdate(markId3)

        Catch ex As NXException

            If ex.ErrorCode = 3520016 Then
                'expression does not exist, create it
                Dim expression1 As Expression
                expression1 = workPart.Expressions.CreateWithUnits("SheetLength=" & sheetLength.ToString, unit1)

                Dim nErrs1 As Integer
                nErrs1 = theSession.UpdateManager.DoUpdate(markId3)

            Else
                'unexpected error, undo all changes made by journal
                theSession.UndoToMark(markId1, undoMarkName)
                MsgBox(ex.ErrorCode & ": " & ex.Message)

            End If

        End Try

        lw.Close()

    End Sub

End Module 

www.nxjournaling.com

RE: Dimensions of a drawing sheet as expressions

(OP)
Thank you! I will check this out!

Industry creates wealth!

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