Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dimensions of a drawing sheet as expressions 1

Status
Not open for further replies.

PrintScaffold

Mechanical
Joined
Sep 8, 2006
Messages
453
Location
RU
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!
 
What version of NX are you on ?
Do you have Teamcenter ?
 
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.
 
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
 
Hello Cowski!

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

Industry creates wealth!
 
I guess it is not possible then?..

Industry creates wealth!
 
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.
 
More like get their values for some other purpose.

Industry creates wealth!
 
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.
 
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.
 
Below is a journal that will create expressions based on the drawing sheet size.

Limitations:
[ul][li]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.[/li]
[li]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.[/li][/ul]

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
 
Thank you! I will check this out!

Industry creates wealth!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top