Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Updating legacy Drawings to new standards

Status
Not open for further replies.

NutAce

Mechanical
Apr 22, 2010
1,192
Hello All,

We have recently updated our Drafting standards and related settings in Customer defaults.
Now when I implement them these new settings will be valid for New parts when created.

I would like to update our legacy data on demand (when revising is needed). I can imagine that we aren't the first ones to do this so...
Is there someone in this community who has created a Script or function to do this with a push on the button?
So user opens legacy drawing, revises and then selects function (button) to update the drawing to new standards file.

Many thanks in advance

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5

HP Zbook15
Intel(R) Core(TM) i7-4800MQ
CPU @ 2.70 GHz Win7 64b
Nvidia K1100M 2048 MB DDR5

 
Replies continue below

Recommended for you

Hi Ronald

We changed from ASME to BS8888 last year and I wrote the following code to change all the annotation settings.

Code:
Imports NXOpen
Imports NXOpen.Preferences

Public Class Fonts

    Shared Sub changeDefaults(ByVal std As String, ByVal textsize As Double)
        Dim mark1 As Session.UndoMarkId
        mark1 = s.SetUndoMark(Session.MarkVisibility.Visible, "Set fonts and linewidths")
        Dim fontIndex1 As Integer

        Dim letteringPreferences1 As Annotations.LetteringPreferences
        letteringPreferences1 = workPart.Annotations.Preferences.GetLetteringPreferences()
        letteringPreferences1.DimAppendedTextSpaceFactor = 0.5
        letteringPreferences1.DimToleranceTextSpaceFactor = 0.5
        letteringPreferences1.AlignmentPosition = Annotations.AlignmentPosition.TopLeft

        Dim dimensionText1 As Annotations.Lettering
        dimensionText1.Size = textsize
        dimensionText1.AspectRatio = 1.0
        dimensionText1.Cfw.Color = 216
        dimensionText1.Cfw.Width = Annotations.LineWidth.Thin
        dimensionText1.Italic = False

        Dim appendedText1 As Annotations.Lettering
        appendedText1.Size = textsize
        appendedText1.AspectRatio = 1.0
        appendedText1.Cfw.Color = 216
        appendedText1.Cfw.Width = Annotations.LineWidth.Thin
        appendedText1.Italic = False

        Dim toleranceText1 As Annotations.Lettering
        toleranceText1.Size = textsize
        toleranceText1.AspectRatio = 1.0
        toleranceText1.Cfw.Color = 216
        toleranceText1.Cfw.Width = Annotations.LineWidth.Thin
        toleranceText1.Italic = False

        '~~~~~~~~~~~~~~~~~~

        Dim standardFontCharacterSpaceFactor1 As Annotations.CharacterSpaceFactor
        standardFontCharacterSpaceFactor1.General = 0.0
        standardFontCharacterSpaceFactor1.Dimension = 0.0
        standardFontCharacterSpaceFactor1.Tolerance = 0.0
        standardFontCharacterSpaceFactor1.Appended = 0.0
        workPart.Annotations.Preferences.SetStandardFontCharacterSpaceFactor(standardFontCharacterSpaceFactor1)

        Dim nxFontCharacterSpaceFactor1 As Annotations.CharacterSpaceFactor
        nxFontCharacterSpaceFactor1.General = 0.01
        nxFontCharacterSpaceFactor1.Dimension = 0.01
        nxFontCharacterSpaceFactor1.Tolerance = 0.01
        nxFontCharacterSpaceFactor1.Appended = 0.01
        workPart.Annotations.Preferences.SetNxFontCharacterSpaceFactor(nxFontCharacterSpaceFactor1)

        '~~~~~~~~~~~~~~~~~~

        Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
        lineAndArrowPreferences1 = workPart.Annotations.Preferences.GetLineAndArrowPreferences()

        lineAndArrowPreferences1.ArrowheadLength = textsize
        lineAndArrowPreferences1.FirstPosToExtLineDist = 1.5
        lineAndArrowPreferences1.SecondPosToExtLineDist = 1.5

        'Dim LineCfw1 As Annotations.LineCfw = New Annotations.LineCfw(216, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)

        'lineAndArrowPreferences1.SetFirstExtensionLineCfw(LineCfw1)
        'lineAndArrowPreferences1.SetFirstArrowheadCfw(LineCfw1)
        'lineAndArrowPreferences1.SetFirstArrowLineCfw(LineCfw1)
        'lineAndArrowPreferences1.SetSecondExtensionLineCfw(LineCfw1)
        'lineAndArrowPreferences1.SetSecondArrowheadCfw(LineCfw1)
        'lineAndArrowPreferences1.SetSecondArrowLineCfw(LineCfw1)

        workPart.Annotations.Preferences.SetLineAndArrowPreferences(lineAndArrowPreferences1)

        lineAndArrowPreferences1.Dispose()

        '~~~~~~~~~~~~~~~~~~

        Dim symbolPreferences1 As Annotations.SymbolPreferences
        symbolPreferences1 = workPart.Annotations.Preferences.GetSymbolPreferences()

        'Dim SymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(216, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
        'symbolPreferences1.SetIdSymbolCfw(SymbolCfw1)
        'symbolPreferences1.SetUserDefinedSymbolCfw(SymbolCfw1)
        'symbolPreferences1.SetIntersectionSymbolCfw(SymbolCfw1)
        'symbolPreferences1.SetTargetSymbolCfw(SymbolCfw1)
        'symbolPreferences1.SetGdtSymbolCfw(SymbolCfw1)
        'symbolPreferences1.SetWeldSymbolCfw(SymbolCfw1)
        'symbolPreferences1.SetSurfaceFinishCfw(SymbolCfw1)
        'Dim centerlineSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(216, 0, Annotations.LineWidth.Thin)
        'symbolPreferences1.SetCenterlineSymbolCfw(centerlineSymbolCfw1)

        symbolPreferences1.WeldSymbolStandard = Annotations.WeldStandard.Iso

        '~~~~~~~~~~~~~~~~~~

        Dim ap As AnnotationPreferences = workPart.Annotations.Preferences()
        Dim dp As Annotations.DimensionPreferences = ap.GetDimensionPreferences()
        Dim up As Annotations.UnitsFormatPreferences = dp.GetUnitsFormatPreferences()
        Dim rp As Annotations.DiameterRadiusPreferences = dp.GetDiameterRadiusPreferences()

        Dim chamfPref As Annotations.ChamferDimensionPreferences = dp.GetChamferDimensionPreferences
        Dim ordPref As Annotations.OrdinateDimensionPreferences = dp.GetOrdinateDimensionPreferences

        Dim narrowPref As Annotations.NarrowDimensionPreferences = dp.GetNarrowDimensionPreferences
        narrowPref.DimensionDisplayOption = Annotations.NarrowDisplayOption.None
        narrowPref.DimensionTextOffset = 10
        narrowPref.DimensionLeaderAngle = 60

        Dim weldstd As Annotations.WeldStandard = workPart.Annotations.WeldStandard
        Dim surfStd As Annotations.SurfaceFinishStandard
        Dim tolStd As UF.UFGdt.Standard

        Dim nullDrawings_SectionLine As Drawings.SectionLine = Nothing
        Dim sectionLineStyleBuilder1 As Drawings.SectionLineStyleBuilder
        sectionLineStyleBuilder1 = workPart.Drafting.SectionLines.CreateSectionLineStyleBuilder(nullDrawings_SectionLine)

        Select Case std
            Case "ASME"
                fontIndex1 = workPart.Fonts.AddFont("ideas_simplex", FontCollection.Type.Nx)
                workPart.Annotations.SetStandardSymbolTextFont("NX ANSI Symbols")
                up.DecimalPointCharacter = Annotations.DecimalPointCharacter.Period
                weldstd = Annotations.WeldStandard.Ansi
                surfStd = Annotations.SurfaceFinishStandard.Ansi
                tolStd = UF.UFGdt.Standard.Asme1994
                dp.TextOrientation = Annotations.TextOrientation.OverDimensionLine
                up.AngularDimensionFormat = Annotations.AngularDimensionFormat.DegreesMinutes
                up.AngularToleranceFormat = Annotations.AngularDimensionFormat.DegreesMinutes
                symbolPreferences1.IdSymbolSize = 32.0
                dimensionText1.CharacterSpaceFactor = 0.01
                dimensionText1.LineSpaceFactor = 0.5
                appendedText1.CharacterSpaceFactor = 0.01
                appendedText1.LineSpaceFactor = 0.5
                toleranceText1.CharacterSpaceFactor = 0.01
                toleranceText1.LineSpaceFactor = 0.5
                narrowPref.DimensionTextOrientation = Annotations.NarrowTextOrientation.Horizontal
                chamfPref.Separator = Annotations.ChamferSeparatorType.UppercaseX
                chamfPref.LeaderPlacement = Annotations.ChamferLeaderPlacement.Perpendicular
                ordPref.LineArrowDisplayOption = 0  '0 = None 1 = All
                ordPref.TextOrientation = Annotations.TextOrientation.OverDimensionLine
                sectionLineStyleBuilder1.ArrowheadLength = 6
                sectionLineStyleBuilder1.ArrowheadAngle = 20
                sectionLineStyleBuilder1.ArrowLength = 15
                sectionLineStyleBuilder1.StubLength = 12
                sectionLineStyleBuilder1.Standard = Drawings.SectionLineStyleBuilder.StandardStyle.AnsiStandard
                sectionLineStyleBuilder1.Width = Drawings.SectionLineStyleBuilder.WidthStyle.ThicknessThree
                rp.DistanceBetweenSymbolAndDimensionText = 0
                rp.SymbolPlacement = Annotations.DiameterRadiusSymbolPlacement.Before
                rp.LeaderStub = Annotations.DiameterRadiusLeaderStub.Before

            Case "BS8888", "ISO"
                fontIndex1 = workPart.Fonts.AddFont("Arial Unicode MS", FontCollection.Type.Standard)
                workPart.Annotations.SetStandardSymbolTextFont("NX ISO Symbols")
                up.DecimalPointCharacter = Annotations.DecimalPointCharacter.Comma
                weldstd = Annotations.WeldStandard.Iso
                surfStd = Annotations.SurfaceFinishStandard.Iso2002
                tolStd = UF.UFGdt.Standard.Iso1983
                dp.TextOrientation = Annotations.TextOrientation.OverDimensionLine
                up.AngularDimensionFormat = Annotations.AngularDimensionFormat.WholeDegrees
                up.AngularToleranceFormat = Annotations.AngularDimensionFormat.WholeDegrees

                dimensionText1.CharacterSpaceFactor = 1.0
                dimensionText1.LineSpaceFactor = 1.0
                appendedText1.CharacterSpaceFactor = 0.5
                appendedText1.LineSpaceFactor = 0.2
                toleranceText1.CharacterSpaceFactor = 0.5
                toleranceText1.LineSpaceFactor = 0.2
                narrowPref.DimensionTextOrientation = Annotations.NarrowTextOrientation.Parallel
                chamfPref.Separator = Annotations.ChamferSeparatorType.LowercaseX
                chamfPref.LeaderPlacement = Annotations.ChamferLeaderPlacement.Linear
                ordPref.LineArrowDisplayOption = 1  '0 = None 1 = All
                ordPref.TextOrientation = Annotations.TextOrientation.OverDimensionLine
                sectionLineStyleBuilder1.ArrowheadLength = 7
                sectionLineStyleBuilder1.ArrowheadAngle = 30
                sectionLineStyleBuilder1.ArrowLength = 25
                sectionLineStyleBuilder1.StubLength = 6
                sectionLineStyleBuilder1.Standard = Drawings.SectionLineStyleBuilder.StandardStyle.Iso128Standard
                sectionLineStyleBuilder1.Width = Drawings.SectionLineStyleBuilder.WidthStyle.ThicknessOne
                sectionLineStyleBuilder1.BorderToArrowDistance = 12
                sectionLineStyleBuilder1.LabelLocation = 0      '0 = On Arrow
                sectionLineStyleBuilder1.ArrowheadStyle = 0     '0 = Closed
                rp.DistanceBetweenSymbolAndDimensionText = 0.1
                rp.SymbolPlacement = Annotations.DiameterRadiusSymbolPlacement.Before
                rp.LeaderStub = Annotations.DiameterRadiusLeaderStub.Below
                If textsize > 4 Then
                    symbolPreferences1.IdSymbolSize = 32.0
                Else
                    symbolPreferences1.IdSymbolSize = 16.0
                End If
        End Select

        dimensionText1.Cfw.Font = fontIndex1
        appendedText1.Cfw.Font = fontIndex1
        toleranceText1.Cfw.Font = fontIndex1

        Dim nxObject1 As NXObject
        nxObject1 = sectionLineStyleBuilder1.Commit()

        workPart.Annotations.Preferences.SetSymbolPreferences(symbolPreferences1)
        symbolPreferences1.Dispose()

        dp.SetOrdinateDimensionPreferences(ordPref)
        dp.SetNarrowDimensionPreferences(narrowPref)
        dp.SetChamferDimensionPreferences(chamfPref)
        dp.SetUnitsFormatPreferences(up)
        dp.SetDiameterRadiusPreferences(rp)
        ap.SetDimensionPreferences(dp)

        lg.WriteLine("fontIndex1 " & fontIndex1)

        dimensionText1.Cfw.Font = fontIndex1
        lg.WriteLine("dimensionText1.Cfw.Font " & dimensionText1.Cfw.Font)
        letteringPreferences1.SetDimensionText(dimensionText1)
        letteringPreferences1.SetAppendedText(appendedText1)
        letteringPreferences1.SetToleranceText(toleranceText1)
        letteringPreferences1.SetGeneralText(dimensionText1)

        workPart.Annotations.Preferences.SetLetteringPreferences(letteringPreferences1)

        letteringPreferences1 = workPart.Annotations.Preferences.GetLetteringPreferences()

        letteringPreferences1.Dispose()

        lg.WriteLine("Decimal point Character = " & up.DecimalPointCharacter.ToString & " (" & up.DecimalPointCharacter & ")")
        lg.WriteLine("End of changeDefaults")

        Dim errs1 As Integer
        errs1 = s.UpdateManager.DoUpdate(mark1)

        s.DeleteUndoMark(mark1, Nothing)

    End Sub
End Class

This is part of a larger program so will need a few modifications to make it standalone. Some settings were not changed so they are commented out. You will see that I included an option to change back. There's always someone that pushes the button when they didn't mean to.

Mike Hyde
NX8.5 with TC9.1
Moving to NX10 with TC11.2
 
Thanks Mike but not exactly what I'm looking for..
You have hard coded the settings...I want them to be taken from our Drafting standards and customer defaults..

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5

HP Zbook15
Intel(R) Core(TM) i7-4800MQ
CPU @ 2.70 GHz Win7 64b
Nvidia K1100M 2048 MB DDR5

 
I posted some code a while back that would compare the customer default setting vs. the part setting. It is just example code (it is far from complete) that compares about a dozen or so dimension style settings. Perhaps it would be of use to get you started...

thread561-372589

www.nxjournaling.com
 
Thanks Cowski....it's a good start

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5

HP Zbook15
Intel(R) Core(TM) i7-4800MQ
CPU @ 2.70 GHz Win7 64b
Nvidia K1100M 2048 MB DDR5

 
I think this would be a useful tool. Does the "refile_part" tool have an option for this?

-Dave

NX 9, Teamcenter 10
 
I don't think that "refile_part" will do this; but it should be noted that the drafting preferences has an "inherit" option that will allow you to inherit settings from the customer defaults.

www.nxjournaling.com
 
cowski said:
I don't think that "refile_part" will do this; but it should be noted that the drafting preferences has an "inherit" option that will allow you to inherit settings from the customer defaults.

That is correct, but you would still have to manually select which objects you want to inherit the customer defaults to.
And this I would like to have as a one button action...automatic selection of ALL entities (Notes, dimensions, labels etc) on drawing which can inherent settings from customer defaults and apply those.

Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5

HP Zbook15
Intel(R) Core(TM) i7-4800MQ
CPU @ 2.70 GHz Win7 64b
Nvidia K1100M 2048 MB DDR5

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor