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?
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
Do you have Teamcenter ?
RE: Dimensions of a drawing sheet as expressions
Industry creates wealth!
RE: Dimensions of a drawing sheet as 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
www.nxjournaling.com
RE: Dimensions of a drawing sheet as expressions
Yes, I mean the dimensions of the sheet itself, width and height.
Industry creates wealth!
RE: Dimensions of a drawing sheet as expressions
Industry creates wealth!
RE: Dimensions of a drawing sheet as 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
Industry creates wealth!
RE: Dimensions of a drawing sheet as 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
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
Limitations:
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 Modulewww.nxjournaling.com
RE: Dimensions of a drawing sheet as expressions
Industry creates wealth!