Return Feature Control Frame in Journal Script
Return Feature Control Frame in Journal Script
(OP)
Hi,
I am trying to create a script that changes the settings for Feature Control Frames, Datum feature Symbols, Notes, etc.
I am new to programming and I am not 100% sure of what I'm doing so I could need some help.
So far I have this Code:
-------------------------------------------------------------------------------------------
Option Strict Off
Imports NXOpen
Module set_dim_text_to_arial
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "change dim text to Arial")
'Declare Font type
Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)
'Change Feature Control Frame Settings
For Each tempFcF As Annotations.DraftingFcf In workPart.Gdts
Dim symbolPreferences1 As Annotations.SymbolPreferences
symbolPreferences1 = tempFcF.GetSymbolPreferences()
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempFcF.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempFcF.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = 0.8
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempFcF.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
symbolPreferences1.SetWeldSpaceFactor(2.0)
symbolPreferences1.SetWeldSymbolSizeFactor(1.0)
Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetWeldSymbolCfw(weldSymbolCfw1)
Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetSurfaceFinishCfw(surfaceFinishCfw1)
symbolPreferences1.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002
symbolPreferences1.WeldSymbolStandard = Annotations.WeldStandard.Iso
tempFcF.SetSymbolPreferences(symbolPreferences1)
symbolPreferences1.Dispose()
tempFcF.LeaderOrientation = Annotations.LeaderOrientation.FromLeft
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Note Settings
For Each tempNote As Annotations.Note In workPart.Notes
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempNote.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempNote.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = 0.8
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempNote.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Label Settings
For Each tempLabel As Annotations.Label In workPart.Labels
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempLabel.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempLabel.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = 0.8
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempLabel.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Settings for DatumFeatureSymbols
For Each tempDatumFeatureSymbol As Annotations.DraftingDatum In workPart.Gdts
Dim symbolPreferences2 As Annotations.SymbolPreferences
symbolPreferences2 = tempDatumFeatureSymbol.GetSymbolPreferences()
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempDatumFeatureSymbol.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempDatumFeatureSymbol.GetLetteringPreferences()
Dim generalText2 As Annotations.Lettering
generalText2.Size = 3.5
generalText2.CharacterSpaceFactor = 0.0
generalText2.AspectRatio = 0.8
generalText2.LineSpaceFactor = 1.0
generalText2.Cfw.Color = 37
generalText2.Cfw.Font = fntArial
generalText2.Cfw.Width = Annotations.LineWidth.Thin
generalText2.Italic = False
letteringPreferences1.SetGeneralText(generalText2)
tempDatumFeatureSymbol.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
symbolPreferences2.SetWeldSpaceFactor(2.0)
symbolPreferences2.SetWeldSymbolSizeFactor(1.0)
Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences2.SetWeldSymbolCfw(weldSymbolCfw1)
Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences2.SetSurfaceFinishCfw(surfaceFinishCfw1)
symbolPreferences2.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002
symbolPreferences2.WeldSymbolStandard = Annotations.WeldStandard.Iso
tempDatumFeatureSymbol.SetSymbolPreferences(symbolPreferences2)
symbolPreferences2.Dispose()
tempDatumFeatureSymbol.LeaderOrientation = Annotations.LeaderOrientation.FromLeft
Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId1)
Next
End Sub
End Module
--------------------------------------------------------------------------------------------
Each section here is working ok, but if I have a drawing that includes both feature control frames and Datum Feature Symbols, it does not work. I think this is because of these lines:
For Each tempFcF As Annotations.DraftingFcf In workPart.Gdts
and this one:
For Each tempDatumFeatureSymbol As Annotations.DraftingDatum In workPart.Gdts
I want to run through all Feature control frames and change the settings for each one. So here I am saving a draftingFcf from workpart.Gdts to tempFcf. Since workpart.Gdts returns both DraftingFcf and
DraftingDatums when the script finds a DraftingDatum and tries to save it as a draftingFcf it crashes.
So my question is how can I search for just DraftingFcfs or just DraftingDatums in my workpart? Or maybe there is a better way of doing this?
Thanks in advance!
Stian L. Amstrup
I am trying to create a script that changes the settings for Feature Control Frames, Datum feature Symbols, Notes, etc.
I am new to programming and I am not 100% sure of what I'm doing so I could need some help.
So far I have this Code:
-------------------------------------------------------------------------------------------
Option Strict Off
Imports NXOpen
Module set_dim_text_to_arial
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "change dim text to Arial")
'Declare Font type
Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)
'Change Feature Control Frame Settings
For Each tempFcF As Annotations.DraftingFcf In workPart.Gdts
Dim symbolPreferences1 As Annotations.SymbolPreferences
symbolPreferences1 = tempFcF.GetSymbolPreferences()
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempFcF.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempFcF.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = 0.8
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempFcF.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
symbolPreferences1.SetWeldSpaceFactor(2.0)
symbolPreferences1.SetWeldSymbolSizeFactor(1.0)
Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetWeldSymbolCfw(weldSymbolCfw1)
Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetSurfaceFinishCfw(surfaceFinishCfw1)
symbolPreferences1.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002
symbolPreferences1.WeldSymbolStandard = Annotations.WeldStandard.Iso
tempFcF.SetSymbolPreferences(symbolPreferences1)
symbolPreferences1.Dispose()
tempFcF.LeaderOrientation = Annotations.LeaderOrientation.FromLeft
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Note Settings
For Each tempNote As Annotations.Note In workPart.Notes
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempNote.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempNote.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = 0.8
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempNote.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Label Settings
For Each tempLabel As Annotations.Label In workPart.Labels
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempLabel.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempLabel.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = 0.8
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempLabel.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Settings for DatumFeatureSymbols
For Each tempDatumFeatureSymbol As Annotations.DraftingDatum In workPart.Gdts
Dim symbolPreferences2 As Annotations.SymbolPreferences
symbolPreferences2 = tempDatumFeatureSymbol.GetSymbolPreferences()
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempDatumFeatureSymbol.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempDatumFeatureSymbol.GetLetteringPreferences()
Dim generalText2 As Annotations.Lettering
generalText2.Size = 3.5
generalText2.CharacterSpaceFactor = 0.0
generalText2.AspectRatio = 0.8
generalText2.LineSpaceFactor = 1.0
generalText2.Cfw.Color = 37
generalText2.Cfw.Font = fntArial
generalText2.Cfw.Width = Annotations.LineWidth.Thin
generalText2.Italic = False
letteringPreferences1.SetGeneralText(generalText2)
tempDatumFeatureSymbol.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
symbolPreferences2.SetWeldSpaceFactor(2.0)
symbolPreferences2.SetWeldSymbolSizeFactor(1.0)
Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences2.SetWeldSymbolCfw(weldSymbolCfw1)
Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences2.SetSurfaceFinishCfw(surfaceFinishCfw1)
symbolPreferences2.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002
symbolPreferences2.WeldSymbolStandard = Annotations.WeldStandard.Iso
tempDatumFeatureSymbol.SetSymbolPreferences(symbolPreferences2)
symbolPreferences2.Dispose()
tempDatumFeatureSymbol.LeaderOrientation = Annotations.LeaderOrientation.FromLeft
Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(markId1)
Next
End Sub
End Module
--------------------------------------------------------------------------------------------
Each section here is working ok, but if I have a drawing that includes both feature control frames and Datum Feature Symbols, it does not work. I think this is because of these lines:
For Each tempFcF As Annotations.DraftingFcf In workPart.Gdts
and this one:
For Each tempDatumFeatureSymbol As Annotations.DraftingDatum In workPart.Gdts
I want to run through all Feature control frames and change the settings for each one. So here I am saving a draftingFcf from workpart.Gdts to tempFcf. Since workpart.Gdts returns both DraftingFcf and
DraftingDatums when the script finds a DraftingDatum and tries to save it as a draftingFcf it crashes.
So my question is how can I search for just DraftingFcfs or just DraftingDatums in my workpart? Or maybe there is a better way of doing this?
Thanks in advance!
Stian L. Amstrup
RE: Return Feature Control Frame in Journal Script
www.nxjournaling.com
RE: Return Feature Control Frame in Journal Script
RE: Return Feature Control Frame in Journal Script
CODE
Option Strict Off Imports NXOpen Module set_dim_text_to_arial Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Sub Main() Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "change dim text to Arial") 'Declare Font type Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard) 'Change GD&T Settings For Each tempFcF As Annotations.Gdt In workPart.Gdts Dim symbolPreferences1 As Annotations.SymbolPreferences symbolPreferences1 = tempFcF.GetSymbolPreferences() Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences lineAndArrowPreferences1 = tempFcF.GetLineAndArrowPreferences() Dim letteringPreferences1 As Annotations.LetteringPreferences letteringPreferences1 = tempFcF.GetLetteringPreferences() Dim generalText1 As Annotations.Lettering generalText1.Size = 3.5 generalText1.CharacterSpaceFactor = 0.0 generalText1.AspectRatio = 0.8 generalText1.LineSpaceFactor = 1.0 generalText1.Cfw.Color = 37 generalText1.Cfw.Font = fntArial generalText1.Cfw.Width = Annotations.LineWidth.Thin generalText1.Italic = False letteringPreferences1.SetGeneralText(generalText1) tempFcF.SetLetteringPreferences(letteringPreferences1) letteringPreferences1.Dispose() lineAndArrowPreferences1.Dispose() symbolPreferences1.SetWeldSpaceFactor(2.0) symbolPreferences1.SetWeldSymbolSizeFactor(1.0) Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin) symbolPreferences1.SetWeldSymbolCfw(weldSymbolCfw1) Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin) symbolPreferences1.SetSurfaceFinishCfw(surfaceFinishCfw1) symbolPreferences1.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002 symbolPreferences1.WeldSymbolStandard = Annotations.WeldStandard.Iso tempFcF.SetSymbolPreferences(symbolPreferences1) symbolPreferences1.Dispose() tempFcF.LeaderOrientation = Annotations.LeaderOrientation.FromLeft Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.DoUpdate(markId1) Next 'Change Note Settings For Each tempNote As Annotations.Note In workPart.Notes Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences lineAndArrowPreferences1 = tempNote.GetLineAndArrowPreferences() Dim letteringPreferences1 As Annotations.LetteringPreferences letteringPreferences1 = tempNote.GetLetteringPreferences() Dim generalText1 As Annotations.Lettering generalText1.Size = 3.5 generalText1.CharacterSpaceFactor = 0.0 generalText1.AspectRatio = 0.8 generalText1.LineSpaceFactor = 1.0 generalText1.Cfw.Color = 37 generalText1.Cfw.Font = fntArial generalText1.Cfw.Width = Annotations.LineWidth.Thin generalText1.Italic = False letteringPreferences1.SetGeneralText(generalText1) tempNote.SetLetteringPreferences(letteringPreferences1) letteringPreferences1.Dispose() lineAndArrowPreferences1.Dispose() Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.DoUpdate(markId1) Next 'Change Label Settings For Each tempLabel As Annotations.Label In workPart.Labels Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences lineAndArrowPreferences1 = tempLabel.GetLineAndArrowPreferences() Dim letteringPreferences1 As Annotations.LetteringPreferences letteringPreferences1 = tempLabel.GetLetteringPreferences() Dim generalText1 As Annotations.Lettering generalText1.Size = 3.5 generalText1.CharacterSpaceFactor = 0.0 generalText1.AspectRatio = 0.8 generalText1.LineSpaceFactor = 1.0 generalText1.Cfw.Color = 37 generalText1.Cfw.Font = fntArial generalText1.Cfw.Width = Annotations.LineWidth.Thin generalText1.Italic = False letteringPreferences1.SetGeneralText(generalText1) tempLabel.SetLetteringPreferences(letteringPreferences1) letteringPreferences1.Dispose() lineAndArrowPreferences1.Dispose() Dim nErrs1 As Integer nErrs1 = theSession.UpdateManager.DoUpdate(markId1) Next End Sub End Module
Optional: you might want to rename the tempFcF variable to more accurately represent what it is used for (perhaps tempGdt).
www.nxjournaling.com
RE: Return Feature Control Frame in Journal Script
RE: Return Feature Control Frame in Journal Script
The code is coming along well, but there is still one thing that does not update to the new settings. It's the section where I change label settings.
All labels get the new settings except "Label on Parent" (i.e. the label you get when you create a detail view).
-----------------------------------------------------------------------
Option Strict Off
Imports NXOpen
Module set_dim_text_to_arial
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "change dim text to Arial")
'Declare Font type
Dim fntArial As Integer = workPart.Fonts.AddFont("Arial", FontCollection.Type.Standard)
'Declare Aspect Ratio
Dim ratio As String = 1
'Change GD&T Settings
For Each tempGdts As Annotations.Gdt In workPart.Gdts
Dim symbolPreferences1 As Annotations.SymbolPreferences
symbolPreferences1 = tempGdts.GetSymbolPreferences()
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempGdts.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempGdts.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempGdts.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
symbolPreferences1.SetWeldSpaceFactor(2.0)
symbolPreferences1.SetWeldSymbolSizeFactor(1.0)
Dim weldSymbolCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetWeldSymbolCfw(weldSymbolCfw1)
Dim surfaceFinishCfw1 As Annotations.LineCfw = New Annotations.LineCfw(37, DisplayableObject.ObjectFont.Solid, Annotations.LineWidth.Thin)
symbolPreferences1.SetSurfaceFinishCfw(surfaceFinishCfw1)
symbolPreferences1.DraftingSurfaceFinishStandard = Annotations.SurfaceFinishStandard.Iso2002
symbolPreferences1.WeldSymbolStandard = Annotations.WeldStandard.Iso
tempGdts.SetSymbolPreferences(symbolPreferences1)
symbolPreferences1.Dispose()
tempGdts.LeaderOrientation = Annotations.LeaderOrientation.FromLeft
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Note Settings
For Each tempNote As Annotations.Note In workPart.Notes
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempNote.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempNote.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempNote.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Label Settings
For Each tempLabel As Annotations.Label In workPart.Labels
Dim lineAndArrowPreferences1 As Annotations.LineAndArrowPreferences
lineAndArrowPreferences1 = tempLabel.GetLineAndArrowPreferences()
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempLabel.GetLetteringPreferences()
Dim generalText1 As Annotations.Lettering
generalText1.Size = 3.5
generalText1.CharacterSpaceFactor = 0.0
generalText1.AspectRatio = ratio
generalText1.LineSpaceFactor = 1.0
generalText1.Cfw.Color = 37
generalText1.Cfw.Font = fntArial
generalText1.Cfw.Width = Annotations.LineWidth.Thin
generalText1.Italic = False
letteringPreferences1.SetGeneralText(generalText1)
tempLabel.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
lineAndArrowPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
'Change Dimension settings
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "change dim text to Arial")
Dim numBad As Integer = 0
For Each tempDim As Annotations.Dimension In workPart.Dimensions
Dim letteringPreferences1 As Annotations.LetteringPreferences
letteringPreferences1 = tempDim.GetLetteringPreferences()
Dim dimensionText1 As Annotations.Lettering = letteringPreferences1.GetDimensionText
Dim appendedText1 As Annotations.Lettering = letteringPreferences1.GetAppendedText
Dim toleranceText1 As Annotations.Lettering = letteringPreferences1.GetToleranceText
Dim mainText() As String
Dim dualText() As String
tempDim.GetDimensionText(mainText, dualText)
If dimensionText1.Size <> 0.01 Then
numBad += 1
dimensionText1.Cfw.Font = fntArial
dimensionText1.Size = 3.5
dimensionText1.AspectRatio = ratio
dimensionText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetDimensionText(dimensionText1)
End If
If appendedText1.Size <> 0.01 Then
numBad += 1
appendedText1.Cfw.Font = fntArial
appendedText1.Size = 3.5
appendedText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetAppendedText(appendedText1)
End If
If toleranceText1.Size <> 0.01 Then
numBad += 1
toleranceText1.Cfw.Font = fntArial
toleranceText1.Size = 3.5
toleranceText1.Cfw.Width = Annotations.LineWidth.Thin
letteringPreferences1.SetToleranceText(toleranceText1)
End If
tempDim.SetLetteringPreferences(letteringPreferences1)
letteringPreferences1.Dispose()
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Next
If numBad > 0 Then
theSession.SetUndoMarkVisibility(markId1, "change dim text to Arial", Session.MarkVisibility.Visible)
End If
'Version up drafting objects
workPart.Drafting.VersionUpAllDraftingObjects()
End Sub
End Module
-----------------------------------
So this part:
For Each tempLabel As Annotations.Label In workPart.Labels
Does not include Label on Parents.
Do you know how I can include those labels as well?
Also, how do you post your code inside that nice CODE box in these threads?
Thanks!
RE: Return Feature Control Frame in Journal Script
As of now I am just creating Journals and trying to figure out which command to use from those. Or i use google.
Documentation that shows what is in each class would be really helpful.
BR
Stian
RE: Return Feature Control Frame in Journal Script
www.nxjournaling.com
RE: Return Feature Control Frame in Journal Script
My code now covers almost every item I need to change, but I am still struggling to include LabelonParent. All other labels change with this code, but LabelOnParent is not included:
For Each tempLabel As Annotations.Label In workPart.Labels
In the .NET API reference guide I can't find a LabelOnParent class. Is there another class that includes this?
Do you know what code I could use to change settings for all LabelOnParents in my drawing.