I have a new Version V3

I worked on my code. In this new version, I can't associate a function ''GetAppendText'' to the ogject ''HoleDimensionSource'' and ''SetAppendText'' to ''HoleDimensionTarget'' object.

I think i have a problem close to the line 252, i dont know how i can convert a ''Hole Dimenssion'' to .tag, how i can fix it ?

Can you help me?

Regards!

Pat
_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*
'NX10.0
'This program allows to assign to a target dimenssions, the properties of a source dimenssions like the option Inherit in dimension properties.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Annotations
Imports NXOpen.Utilities

Module NXJournal
Public test As String
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim WorkPart As Part = theSession.Parts.Work
Dim Drafting As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim ObjSource As TaggedObject = Nothing
Dim HoleDimensionTarget As Annotations.HoleDimension = Nothing
Dim HoleDimensionSource As Annotations.HoleDimension = Nothing

Sub Main()

lw.Open()
lw.WriteLine("Debug = Pts 0.0")
lw.WriteLine("This program allows to assign to a target dimenssions,")
lw.WriteLine("the properties of a source dimenssions like the function Inherit.")

Dim DimEditSettingTarget As Annotations.EditSettingsBuilder = Nothing
Dim DimEditSettingSource(0) As Drafting.BaseEditSettingsBuilder

Dim MarkId1 As Session.UndoMarkId

'Select one or more target dimensions
While Select_Dimension_Target("Select target Dim", HoleDimensionTarget) = Selection.Response.Ok

lw.WriteLine("Select target Dim: " & HoleDimensionTarget.ToString())
MarkId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim Objects1(0) As DisplayableObject
Objects1(0) = HoleDimensionTarget
DimEditSettingTarget = WorkPart.SettingsManager.CreateAnnotationEditSettingsBuilder(Objects1)
lw.WriteLine("Debug = Pts 1.0")
End While
lw.WriteLine("Debug = Pts 1.1")

'Select an original dimension
While Select_Dimension_Source("Select source Dim (Inherit)", HoleDimensionSource) = Selection.Response.Ok
lw.WriteLine("Select source Dim (Inherit): " & HoleDimensionSource.ToString())

Dim theUI As UI = UI.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
Dim type As Integer
Dim subtype As Integer
lw.Open()
lw.WriteLine("Selected Objects: " & numsel.ToString())

ufs.Obj.AskTypeAndSubtype(HoleDimensionSource.Tag, type, subtype)
lw.WriteLine("Object: " & HoleDimensionSource.ToString())
lw.WriteLine(" Tag: " & HoleDimensionSource.Tag.ToString())
lw.WriteLine(" Type: " & type.ToString())
lw.WriteLine(" Subtype: " & subtype.ToString())

''Get Appended text from source dimenssion; Before + Above + After + Below
'Dim SourceAppendedTextBefore As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim LineGetBefore(0) As String
'LineGetBefore(0) = Nothing
'LineGetBefore = SourceAppendedTextBefore.GetBefore()
'lw.WriteLine("Line Before Source: " & SourceAppendedTextBefore.ToString())

'Dim SourceAppendedTextAbove As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim LineGetAbove(0) As String
'LineGetAbove(0) = Nothing
'LineGetAbove = SourceAppendedTextAbove.GetAbove()
'lw.WriteLine("Line Above Source: " & SourceAppendedTextAbove.ToString())

''Set Appended text to target dimenssions; Before + Above + After + Below
'Dim HoleDimensionTargetTextBefore As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim TargetAppendedTextBefore As NXOpen.Annotations.AppendedText = Nothing
'HoleDimensionTargetTextBefore.SetBefore(LineGetBefore)

'Dim HoleDimensionTargetTextAbove As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim TargetAppendedTextAbove As NXOpen.Annotations.AppendedText = Nothing
'HoleDimensionTargetTextAbove.SetAbove(LineGetAbove)

'ufs.Modl.Update()

'Dim DimEditSettingSource(0) As Drafting.BaseEditSettingsBuilder
DimEditSettingSource(0) = DimEditSettingTarget
WorkPart.SettingsManager.ProcessForMultipleObjectsSettings(DimEditSettingSource)
DimEditSettingTarget.InheritSettingsFromSelectedObjects(HoleDimensionSource)

Dim NXObject1 As NXObject
NXObject1 = DimEditSettingTarget.Commit()
DimEditSettingTarget.Destroy()
lw.WriteLine("Debug = Pts 1.2")

TestAppenText()

End While
lw.WriteLine("Debug = Pts 1.3")

End Sub
Function Select_Dimension_Target(ByVal prompt As String, ByRef obj As Dimension)
Dim ui As UI = GetUI()

Dim theUI As UI = ui.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
lw.WriteLine("Selected Objects: " & numsel.ToString())

Dim Mask(0) As Selection.MaskTriple
With Mask(0)
.Type = UFConstants.UF_dimension_type
.Subtype = 0
.SolidBodySubtype = 0
End With
Dim Cursor As Point3d = Nothing

Dim Resp As Selection.Response = _
ui.SelectionManager.SelectTaggedObject(prompt, prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, Mask, obj, Cursor)
lw.WriteLine("Debug = Pts 1.4")
If Resp = Selection.Response.ObjectSelected Or _
Resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
lw.WriteLine("Dimension cible: ok ")
Else
Return Selection.Response.Cancel
End If
lw.WriteLine("Debug = Pts 1.5")
End Function
Function Select_Dimension_Source(ByVal prompt As String, ByRef obj As Dimension)

Dim Mask() As Selection.MaskTriple = _
{New Selection.MaskTriple(UFConstants.UF_dimension_type, 0, 0)}

Dim ui2 As UI = GetUI()
Dim Cursor2 As Point3d = Nothing
'Dim ObjSource As TaggedObject = Nothing

Dim Resp2 As Selection.Response = _
ui2.SelectionManager.SelectTaggedObject(prompt, prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, Mask, obj, Cursor2)
lw.WriteLine("Debug = Pts 1.6")
If Resp2 = Selection.Response.ObjectSelected Or _
Resp2 = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Return CType(ObjSource, Dimension)
Else
Return Selection.Response.Cancel
End If
lw.WriteLine("Debug = Pts 1.7")

End Function

Private Function selectNotes(ByVal prompt As String) As Annotations.Note()
Dim Mask(0) As Selection.MaskTriple
With Mask(0)
.Type = UFConstants.UF_drafting_entity_type
.Subtype = UFConstants.UF_draft_note_subtype
.SolidBodySubtype = 0
End With
Dim cursor As Point3d = Nothing
Dim TheObjects() As TaggedObject = Nothing

UI.GetUI().SelectionManager.SelectTaggedObjects("Select Notes", prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, Mask, TheObjects)

Dim TheNotes(TheObjects.Length - 1) As Annotations.Note
For ii As Integer = 0 To TheObjects.Length - 1
TheNotes(ii) = CType(TheObjects(ii), Annotations.Note)
Next

Return theNotes

End Function

'---***---
Function TestAppenText()

Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

'Dim holeDimension1 As NXOpen.Annotations.HoleDimension = CType(workPart.FindObject("HANDLE R-415279"), NXOpen.Annotations.HoleDimension)

Dim radialDimensionBuilder1 As NXOpen.Annotations.RadialDimensionBuilder
radialDimensionBuilder1 = WorkPart.Dimensions.CreateRadialDimensionBuilder(HoleDimensionSource) '(holeDimension1)

radialDimensionBuilder1.Driving.DrivingMethod = NXOpen.Annotations.DrivingValueBuilder.DrivingValueMethod.Inferred

radialDimensionBuilder1.Driving.Reference = True

radialDimensionBuilder1.Driving.DrivingMethod = NXOpen.Annotations.DrivingValueBuilder.DrivingValueMethod.Reference

theSession.SetUndoMarkName(markId1, "Radial Dimension Dialog")

radialDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)

radialDimensionBuilder1.Style.OrdinateStyle.DoglegCreationOption = NXOpen.Annotations.OrdinateDoglegCreationOption.No

radialDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)

radialDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)

Dim nullNXOpen_Direction As NXOpen.Direction = Nothing

radialDimensionBuilder1.Measurement.Direction = nullNXOpen_Direction

Dim nullNXOpen_View As NXOpen.View = Nothing

radialDimensionBuilder1.Measurement.DirectionView = nullNXOpen_View

Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

theSession.DeleteUndoMark(markId2, Nothing)

Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

theSession.DeleteUndoMark(markId3, Nothing)

Dim markId4 As NXOpen.Session.UndoMarkId
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

Dim markId5 As NXOpen.Session.UndoMarkId
markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start")

theSession.SetUndoMarkName(markId5, "Appended Text Dialog")

theSession.SetUndoMarkVisibility(markId5, Nothing, NXOpen.Session.MarkVisibility.Visible)

' ----------------------------------------------
' Dialog Begin Appended Text
' ----------------------------------------------

'Get Appended text from source dimenssion; Before + Above + After + Below

Dim dimObj As Annotations.Dimension = NXObjectManager.Get(HoleDimensionSource.Tag)
Dim SourceAppendedTextBefore As NXOpen.Annotations.AppendedText = dimObj.GetAppendedText()
Dim LineGetBefore(0) As String
LineGetBefore = SourceAppendedTextBefore.GetBeforeText()
radialDimensionBuilder1.AppendedText.SetBelow(LineGetBefore)
lw.WriteLine("Line Before Source: " & SourceAppendedTextBefore.ToString.ToString())
dimObj.SetAppendedText(SourceAppendedTextBefore)
ufs.Modl.Update()

'Dim LineGetBefore(0) As String
'LineGetBefore(0) = Nothing
'LineGetBefore = SourceAppendedTextBefore.GetBefore()
'lw.WriteLine("Line Before Source: " & SourceAppendedTextBefore.ToString())

'Dim SourceAppendedTextAbove As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim LineGetAbove(0) As String
'LineGetAbove(0) = Nothing
'LineGetAbove = SourceAppendedTextAbove.GetAbove()
'lw.WriteLine("Line Above Source: " & SourceAppendedTextAbove.ToString())

Dim markId6 As NXOpen.Session.UndoMarkId
markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Appended Text")

'Dim HoleDimensionTargetTextBefore As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim TargetAppendedTextBefore As NXOpen.Annotations.AppendedText = Nothing
'HoleDimensionTargetTextBefore.SetBefore(LineGetBefore)

'Dim lines1(0) As String
'lines1(0) = "Devant"
'radialDimensionBuilder1.AppendedText.SetBefore(lines1)

'Dim lines2(0) As String
'lines2(0) = "Apres"
'radialDimensionBuilder1.AppendedText.SetAfter(lines2)

'Dim lines3(0) As String
'lines3(0) = "Dessus"
'radialDimensionBuilder1.AppendedText.SetAbove(lines3)

'Dim lines4(0) As String
'lines4(0) = "Dessous"
'radialDimensionBuilder1.AppendedText.SetBelow(lines4)

theSession.SetUndoMarkName(markId6, "Appended Text - Selection")

theSession.SetUndoMarkVisibility(markId6, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.SetUndoMarkVisibility(markId5, Nothing, NXOpen.Session.MarkVisibility.Invisible)

Dim markId7 As NXOpen.Session.UndoMarkId
markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Appended Text")

Dim lines5(0) As String
lines5(0) = "Devant"
radialDimensionBuilder1.AppendedText.SetBefore(lines5)

Dim markId8 As NXOpen.Session.UndoMarkId
markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Appended Text")

theSession.DeleteUndoMark(markId8, Nothing)

theSession.SetUndoMarkName(markId5, "Appended Text")

theSession.DeleteUndoMark(markId7, Nothing)

theSession.SetUndoMarkVisibility(markId5, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.DeleteUndoMark(markId6, Nothing)

theSession.DeleteUndoMark(markId5, Nothing)

theSession.SetUndoMarkName(markId4, "Radial Dimension")

theSession.SetUndoMarkVisibility(markId4, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.SetUndoMarkVisibility(markId1, Nothing, NXOpen.Session.MarkVisibility.Invisible)

Dim markId9 As NXOpen.Session.UndoMarkId
markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

Dim markId10 As NXOpen.Session.UndoMarkId
markId10 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

Dim nXObject1 As NXOpen.NXObject
nXObject1 = radialDimensionBuilder1.Commit()

theSession.DeleteUndoMark(markId10, Nothing)

theSession.SetUndoMarkName(markId1, "Radial Dimension")

radialDimensionBuilder1.Destroy()

theSession.DeleteUndoMark(markId9, Nothing)

theSession.SetUndoMarkVisibility(markId1, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.DeleteUndoMark(markId4, Nothing)

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY

'Unloads the image when the NX session terminates
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module

'NX10.0
'This program allows to assign to a target dimenssions, the properties of a source dimenssions like the option Inherit in dimension properties.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Annotations
Imports NXOpen.Utilities

Module NXJournal
Public test As String
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim WorkPart As Part = theSession.Parts.Work
Dim Drafting As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim ObjSource As TaggedObject = Nothing
Dim HoleDimensionTarget As Annotations.HoleDimension = Nothing
Dim HoleDimensionSource As Annotations.HoleDimension = Nothing

Sub Main()

lw.Open()
lw.WriteLine("Debug = Pts 0.0")
lw.WriteLine("This program allows to assign to a target dimenssions,")
lw.WriteLine("the properties of a source dimenssions like the function Inherit.")

Dim DimEditSettingTarget As Annotations.EditSettingsBuilder = Nothing
Dim DimEditSettingSource(0) As Drafting.BaseEditSettingsBuilder

Dim MarkId1 As Session.UndoMarkId

'Select one or more target dimensions
While Select_Dimension_Target("Select target Dim", HoleDimensionTarget) = Selection.Response.Ok

lw.WriteLine("Select target Dim: " & HoleDimensionTarget.ToString())
MarkId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim Objects1(0) As DisplayableObject
Objects1(0) = HoleDimensionTarget
DimEditSettingTarget = WorkPart.SettingsManager.CreateAnnotationEditSettingsBuilder(Objects1)
lw.WriteLine("Debug = Pts 1.0")
End While
lw.WriteLine("Debug = Pts 1.1")

'Select an original dimension
While Select_Dimension_Source("Select source Dim (Inherit)", HoleDimensionSource) = Selection.Response.Ok
lw.WriteLine("Select source Dim (Inherit): " & HoleDimensionSource.ToString())

Dim theUI As UI = UI.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
Dim type As Integer
Dim subtype As Integer
lw.Open()
lw.WriteLine("Selected Objects: " & numsel.ToString())

ufs.Obj.AskTypeAndSubtype(HoleDimensionSource.Tag, type, subtype)
lw.WriteLine("Object: " & HoleDimensionSource.ToString())
lw.WriteLine(" Tag: " & HoleDimensionSource.Tag.ToString())
lw.WriteLine(" Type: " & type.ToString())
lw.WriteLine(" Subtype: " & subtype.ToString())

''Get Appended text from source dimenssion; Before + Above + After + Below
'Dim SourceAppendedTextBefore As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim LineGetBefore(0) As String
'LineGetBefore(0) = Nothing
'LineGetBefore = SourceAppendedTextBefore.GetBefore()
'lw.WriteLine("Line Before Source: " & SourceAppendedTextBefore.ToString())

'Dim SourceAppendedTextAbove As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim LineGetAbove(0) As String
'LineGetAbove(0) = Nothing
'LineGetAbove = SourceAppendedTextAbove.GetAbove()
'lw.WriteLine("Line Above Source: " & SourceAppendedTextAbove.ToString())

''Set Appended text to target dimenssions; Before + Above + After + Below
'Dim HoleDimensionTargetTextBefore As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim TargetAppendedTextBefore As NXOpen.Annotations.AppendedText = Nothing
'HoleDimensionTargetTextBefore.SetBefore(LineGetBefore)

'Dim HoleDimensionTargetTextAbove As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim TargetAppendedTextAbove As NXOpen.Annotations.AppendedText = Nothing
'HoleDimensionTargetTextAbove.SetAbove(LineGetAbove)

'ufs.Modl.Update()

'Dim DimEditSettingSource(0) As Drafting.BaseEditSettingsBuilder
DimEditSettingSource(0) = DimEditSettingTarget
WorkPart.SettingsManager.ProcessForMultipleObjectsSettings(DimEditSettingSource)
DimEditSettingTarget.InheritSettingsFromSelectedObjects(HoleDimensionSource)

Dim NXObject1 As NXObject
NXObject1 = DimEditSettingTarget.Commit()
DimEditSettingTarget.Destroy()
lw.WriteLine("Debug = Pts 1.2")

TestAppenText()

End While
lw.WriteLine("Debug = Pts 1.3")

End Sub
Function Select_Dimension_Target(ByVal prompt As String, ByRef obj As Dimension)
Dim ui As UI = GetUI()

Dim theUI As UI = ui.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
lw.WriteLine("Selected Objects: " & numsel.ToString())

Dim Mask(0) As Selection.MaskTriple
With Mask(0)
.Type = UFConstants.UF_dimension_type
.Subtype = 0
.SolidBodySubtype = 0
End With
Dim Cursor As Point3d = Nothing

Dim Resp As Selection.Response = _
ui.SelectionManager.SelectTaggedObject(prompt, prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, Mask, obj, Cursor)
lw.WriteLine("Debug = Pts 1.4")
If Resp = Selection.Response.ObjectSelected Or _
Resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
lw.WriteLine("Dimension cible: ok ")
Else
Return Selection.Response.Cancel
End If
lw.WriteLine("Debug = Pts 1.5")
End Function
Function Select_Dimension_Source(ByVal prompt As String, ByRef obj As Dimension)

Dim Mask() As Selection.MaskTriple = _
{New Selection.MaskTriple(UFConstants.UF_dimension_type, 0, 0)}

Dim ui2 As UI = GetUI()
Dim Cursor2 As Point3d = Nothing
'Dim ObjSource As TaggedObject = Nothing

Dim Resp2 As Selection.Response = _
ui2.SelectionManager.SelectTaggedObject(prompt, prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, Mask, obj, Cursor2)
lw.WriteLine("Debug = Pts 1.6")
If Resp2 = Selection.Response.ObjectSelected Or _
Resp2 = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Return CType(ObjSource, Dimension)
Else
Return Selection.Response.Cancel
End If
lw.WriteLine("Debug = Pts 1.7")

End Function

Private Function selectNotes(ByVal prompt As String) As Annotations.Note()
Dim Mask(0) As Selection.MaskTriple
With Mask(0)
.Type = UFConstants.UF_drafting_entity_type
.Subtype = UFConstants.UF_draft_note_subtype
.SolidBodySubtype = 0
End With
Dim cursor As Point3d = Nothing
Dim TheObjects() As TaggedObject = Nothing

UI.GetUI().SelectionManager.SelectTaggedObjects("Select Notes", prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, Mask, TheObjects)

Dim TheNotes(TheObjects.Length - 1) As Annotations.Note
For ii As Integer = 0 To TheObjects.Length - 1
TheNotes(ii) = CType(TheObjects(ii), Annotations.Note)
Next

Return theNotes

End Function

'---***---
Function TestAppenText()

Dim markId1 As NXOpen.Session.UndoMarkId
markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

'Dim holeDimension1 As NXOpen.Annotations.HoleDimension = CType(workPart.FindObject("HANDLE R-415279"), NXOpen.Annotations.HoleDimension)

Dim radialDimensionBuilder1 As NXOpen.Annotations.RadialDimensionBuilder
radialDimensionBuilder1 = WorkPart.Dimensions.CreateRadialDimensionBuilder(HoleDimensionSource) '(holeDimension1)

radialDimensionBuilder1.Driving.DrivingMethod = NXOpen.Annotations.DrivingValueBuilder.DrivingValueMethod.Inferred

radialDimensionBuilder1.Driving.Reference = True

radialDimensionBuilder1.Driving.DrivingMethod = NXOpen.Annotations.DrivingValueBuilder.DrivingValueMethod.Reference

theSession.SetUndoMarkName(markId1, "Radial Dimension Dialog")

radialDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)

radialDimensionBuilder1.Style.OrdinateStyle.DoglegCreationOption = NXOpen.Annotations.OrdinateDoglegCreationOption.No

radialDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)

radialDimensionBuilder1.Origin.SetInferRelativeToGeometry(True)

Dim nullNXOpen_Direction As NXOpen.Direction = Nothing

radialDimensionBuilder1.Measurement.Direction = nullNXOpen_Direction

Dim nullNXOpen_View As NXOpen.View = Nothing

radialDimensionBuilder1.Measurement.DirectionView = nullNXOpen_View

Dim markId2 As NXOpen.Session.UndoMarkId
markId2 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

theSession.DeleteUndoMark(markId2, Nothing)

Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

theSession.DeleteUndoMark(markId3, Nothing)

Dim markId4 As NXOpen.Session.UndoMarkId
markId4 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

Dim markId5 As NXOpen.Session.UndoMarkId
markId5 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start")

theSession.SetUndoMarkName(markId5, "Appended Text Dialog")

theSession.SetUndoMarkVisibility(markId5, Nothing, NXOpen.Session.MarkVisibility.Visible)

' ----------------------------------------------
' Dialog Begin Appended Text
' ----------------------------------------------

'Get Appended text from source dimenssion; Before + Above + After + Below

Dim dimObj As Annotations.Dimension = NXObjectManager.Get(HoleDimensionSource.Tag)
Dim SourceAppendedTextBefore As NXOpen.Annotations.AppendedText = dimObj.GetAppendedText()
Dim LineGetBefore(0) As String
LineGetBefore = SourceAppendedTextBefore.GetBeforeText()
radialDimensionBuilder1.AppendedText.SetBelow(LineGetBefore)
lw.WriteLine("Line Before Source: " & SourceAppendedTextBefore.ToString.ToString())
dimObj.SetAppendedText(SourceAppendedTextBefore)
ufs.Modl.Update()

'Dim LineGetBefore(0) As String
'LineGetBefore(0) = Nothing
'LineGetBefore = SourceAppendedTextBefore.GetBefore()
'lw.WriteLine("Line Before Source: " & SourceAppendedTextBefore.ToString())

'Dim SourceAppendedTextAbove As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim LineGetAbove(0) As String
'LineGetAbove(0) = Nothing
'LineGetAbove = SourceAppendedTextAbove.GetAbove()
'lw.WriteLine("Line Above Source: " & SourceAppendedTextAbove.ToString())

Dim markId6 As NXOpen.Session.UndoMarkId
markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Appended Text")

'Dim HoleDimensionTargetTextBefore As NXOpen.Annotations.AppendedTextBuilder = Nothing
'Dim TargetAppendedTextBefore As NXOpen.Annotations.AppendedText = Nothing
'HoleDimensionTargetTextBefore.SetBefore(LineGetBefore)

'Dim lines1(0) As String
'lines1(0) = "Devant"
'radialDimensionBuilder1.AppendedText.SetBefore(lines1)

'Dim lines2(0) As String
'lines2(0) = "Apres"
'radialDimensionBuilder1.AppendedText.SetAfter(lines2)

'Dim lines3(0) As String
'lines3(0) = "Dessus"
'radialDimensionBuilder1.AppendedText.SetAbove(lines3)

'Dim lines4(0) As String
'lines4(0) = "Dessous"
'radialDimensionBuilder1.AppendedText.SetBelow(lines4)

theSession.SetUndoMarkName(markId6, "Appended Text - Selection")

theSession.SetUndoMarkVisibility(markId6, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.SetUndoMarkVisibility(markId5, Nothing, NXOpen.Session.MarkVisibility.Invisible)

Dim markId7 As NXOpen.Session.UndoMarkId
markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Appended Text")

Dim lines5(0) As String
lines5(0) = "Devant"
radialDimensionBuilder1.AppendedText.SetBefore(lines5)

Dim markId8 As NXOpen.Session.UndoMarkId
markId8 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Appended Text")

theSession.DeleteUndoMark(markId8, Nothing)

theSession.SetUndoMarkName(markId5, "Appended Text")

theSession.DeleteUndoMark(markId7, Nothing)

theSession.SetUndoMarkVisibility(markId5, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.DeleteUndoMark(markId6, Nothing)

theSession.DeleteUndoMark(markId5, Nothing)

theSession.SetUndoMarkName(markId4, "Radial Dimension")

theSession.SetUndoMarkVisibility(markId4, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.SetUndoMarkVisibility(markId1, Nothing, NXOpen.Session.MarkVisibility.Invisible)

Dim markId9 As NXOpen.Session.UndoMarkId
markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

Dim markId10 As NXOpen.Session.UndoMarkId
markId10 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Radial Dimension")

Dim nXObject1 As NXOpen.NXObject
nXObject1 = radialDimensionBuilder1.Commit()

theSession.DeleteUndoMark(markId10, Nothing)

theSession.SetUndoMarkName(markId1, "Radial Dimension")

radialDimensionBuilder1.Destroy()

theSession.DeleteUndoMark(markId9, Nothing)

theSession.SetUndoMarkVisibility(markId1, Nothing, NXOpen.Session.MarkVisibility.Visible)

theSession.DeleteUndoMark(markId4, Nothing)

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY

'Unloads the image when the NX session terminates
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module

The code below illustrates one way to copy the appended text from one dimension to another. When run, it will prompt you to select a "source" dimension then a "target" dimension; the journal will copy the appended text from the source to the target.

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 = "inherit appended text"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim sourceDim As Annotations.Dimension
Dim targetDim As Annotations.Dimension

If SelectDimension("select source dimension", sourceDim) = Selection.Response.Cancel Then
Return
End If

If SelectDimension("select target dimension", targetDim) = Selection.Response.Cancel Then
Return
End If

targetDim.SetAppendedText(sourceDim.GetAppendedText)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)

lw.Close()

End Sub

Function SelectDimension(ByVal prompt As String, ByRef selObj As NXObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select a dimension"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UF.UFConstants.UF_dimension_type
.Subtype = UF.UFConstants.UF_all_subtype
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

End Module

Hi !!!

It's a good job and tank you to help me !!!

However, I would like the user can select more than one target dimenssion.

And also, I would like the units Inherit. If the source is fractional units, I wouls to apply same units to all tartget dimenssions.

I think the code need to select all target Dimenssions first ? No? But, I'm not sure... you are the Pro !!!

User NXjournaling , you are a single people or a team of people ?

Regards !

Pat

The code was only to illustrate how to copy appended text from one dimension to another. You can use a similar strategy with .GetDimensionPreferences / .SetDimensionPreferences, .GetLetteringPreferences / .SetLetteringPreferences, and others.

As for selecting multiple target dimensions, I suggest using the function: .SelectTaggedObjects rather than the function used in my example code: .SelectObject. The .SelectObject function only allows one object to be selected and it is an older, deprecated function. .SelectTaggedObjects will allow you to select multiple objects.

I trying to fix my code with you example, but i have an Error on line 64, can you help ?

Message:
''System.NullReferenceException: La référence d'objet n'est pas définie à une instance d'un objet.
à NXJournal.Main() dans C:\Users\Admin\AppData\Local\Temp\NXJournals952\journal.vb:ligne 64

Tank you
Regards

'NX10.0
'This program allows to assign to a target dimenssions, the properties of a source dimenssions like the option Inherit in dimension properties.

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.UF
Imports NXOpen.Annotations
Imports NXOpen.Utilities

Module NXJournal
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim WorkPart As Part = theSession.Parts.Work
Dim Drafting As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim ObjSource As TaggedObject = Nothing

Sub Main()

lw.Open()
lw.WriteLine("This program allows to assign to a target dimenssions,")
lw.WriteLine("the properties of a source dimenssions like the function Inherit.")

'_*_*_*_*__*_*_Active part required_*_*__*_*__*_*_
If IsNothing(theSession.Parts.Work) Then
Return
End If

'_*_*_*_*__*_*_Undo mark_*_*__*_*__*_*_
Const UndoMarkNameId2 As String = "Inherit appended text"
Dim MarkId2 As Session.UndoMarkId
MarkId2 = theSession.SetUndoMark(Session.MarkVisibility.Visible, UndoMarkNameId2)

Const UndoMarkNameId1 As String = "Start"
Dim MarkId1 As Session.UndoMarkId
MarkId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, UndoMarkNameId1)

'_*_*_*_*__*_*_Select target dimension_*_*__*_*__*_*_
Dim TargetDim As Annotations.Dimension = Nothing
Dim TargetDimSetting As Annotations.EditSettingsBuilder = Nothing
While SelectTargetDim("Select target Dim", TargetDim) = Selection.Response.Ok

lw.WriteLine("Select target Dim: " & TargetDim.ToString())
Dim Objects1(0) As DisplayableObject
Objects1(0) = TargetDim
TargetDimSetting = WorkPart.SettingsManager.CreateAnnotationEditSettingsBuilder(Objects1)
End While

'_*_*_*_*__*_*_Select source dimension_*_*__*_*__*_*_
Dim SourceDim As Annotations.Dimension = Nothing
If SelectSourceDim("Select source dimension", SourceDim) = Selection.Response.Cancel Then
Return
End If

lw.WriteLine("Select source Dim: " & SourceDim.ToString())

'_*_*_*_*__*_*_Inherit Appended text_*_*__*_*__*_*_
TargetDim.SetAppendedText(SourceDim.GetAppendedText)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(MarkId2)

'_*_*_*_*__*_*_Inherit Settings_*_*__*_*__*_*_
Dim SourceDimSetting(0) As Drafting.BaseEditSettingsBuilder
SourceDimSetting(0) = TargetDimSetting
WorkPart.SettingsManager.ProcessForMultipleObjectsSettings(SourceDimSetting)
TargetDimSetting.InheritSettingsFromSelectedObjects(SourceDim)

Dim NXObject1 As NXObject
NXObject1 = TargetDimSetting.Commit()
TargetDimSetting.Destroy()

End Sub

Function SelectTargetDim(ByVal prompt As String, ByRef obj As Dimension)
Dim ui As UI = GetUI()

Dim theUI As UI = ui.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
lw.WriteLine("Selected Objects: " & numsel.ToString())

Dim Mask(0) As Selection.MaskTriple
With Mask(0)
.Type = UFConstants.UF_dimension_type
.Subtype = 0
.SolidBodySubtype = 0
End With
Dim Cursor As Point3d = Nothing

Dim Resp As Selection.Response = _
ui.SelectionManager.SelectTaggedObject(prompt, prompt, _
Selection.SelectionScope.AnyInAssembly, _
Selection.SelectionAction.ClearAndEnableSpecific, _
False, False, Mask, obj, Cursor)

If Resp = Selection.Response.ObjectSelected Or _
Resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok

Else
Return Selection.Response.Cancel
End If

End Function
Function SelectSourceDim(ByVal prompt As String, ByRef selObj As NXObject) As Selection.Response

Dim theUI As UI = UI.GetUI
Dim title As String = "Select a dimension"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor2 As Point3d = Nothing
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UFConstants.UF_dimension_type
.Subtype = 0
.SolidBodySubtype = 0
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selObj, cursor2)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

Public Function GetUnloadOption(ByVal dummy As String) As Integer

GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY

'Unloads the image when the NX session terminates
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

'----Other unload options-------
'Unloads the image immediately after execution within NX
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

'Unloads the image explicitly, via an unload dialog
'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
'-------------------------------
End Function
End Module

Pat

Rather than working through your code, I've extended my previous example 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 = "inherit appended text"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

Dim sourceDim As Annotations.Dimension
Dim targetDim As Annotations.Dimension

If SelectDimension("select source dimension", sourceDim) = Selection.Response.Cancel Then
Return
End If

Do Until SelectDimension("select target dimension", targetDim) = Selection.Response.Cancel
targetDim.SetAppendedText(sourceDim.GetAppendedText)
targetDim.SetDimensionPreferences(sourceDim.GetDimensionPreferences)
targetDim.SetLineAndArrowPreferences(sourceDim.GetLineAndArrowPreferences)
targetDim.SetLetteringPreferences(sourceDim.GetLetteringPreferences)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId1)
Loop

lw.Close()

End Sub

Function SelectDimension(ByVal prompt As String, ByRef selObj As NXObject) As Selection.Response

Dim theUI As UI = UI.GetUI
'Dim title As String = "Select a dimension"
Dim title As String = prompt
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim cursor As Point3d
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple

With selectionMask_array(0)
.Type = UF.UFConstants.UF_dimension_type
.Subtype = UF.UFConstants.UF_all_subtype
End With

Dim resp As Selection.Response = theUI.SelectionManager.SelectObject(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selObj, cursor)
If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If

End Function

End Module

This is exactly what I need, good job!

I understand better how I should do

Thank you for your help!

Pat