×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

nx journal to create Index number at dimension with adjusted orientation

nx journal to create Index number at dimension with adjusted orientation

nx journal to create Index number at dimension with adjusted orientation

(OP)
Hello,
I am trying to create an Index number to a selected dimension. For this I found a very helpful journal in this forum that I modified a bit. Now I need to adjust the text angle of the ID Symbol to match the diminsion's orientation. Dimensions do not have a lettering angle in the style dialog like notes. Therefore I wanted to use the TextOrienationAngle from the dimension.
But I allways get an error:
"Line 56: "GetDimensionPreferences" is not a member of "NXOpen.Annotations.Annotation"

CODE -->

'journal to Create Non- Associative Index Numbers at Dimensions or Notes

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


Module NXJournal
Sub Main

'*************************************************************************
'change the following offset distances to get something that works for you
'offsets from dimension text
Const XOffsetDim as Double = 0
Const YOffsetDim as Double = 2
'offsets from notes
Const XOffsetNote as Double = -3
Const YOffsetNote as Double = 0
'*************************************************************************

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim lw As ListingWindow = theSession.ListingWindow
Dim noteDim As Annotation
Dim noteDimOrigin as Point3D = Nothing
Dim letterPref as LetteringPreferences = Nothing
Dim symbolPref as SymbolPreferences = Nothing
Dim dimpref as DimensionPreferences = Nothing
Dim noteNumber as Integer
Dim letterangle as String
Dim dimangle as String
Dim input as String
Dim theAnnotationManager as NXOpen.Annotations.AnnotationManager = workPart.Annotations

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

Do
	input = InputBox("Enter starting INDEX number: ", "Create Index Numbers at Dimensions or Notes", "")
Loop Until (isNumeric(input))
noteNumber = input

lw.Open()

While selectNoteDimension("Select Dimension or Note", noteDim) = Selection.Response.Ok
	noteDimOrigin = noteDim.AnnotationOrigin
	'lw.WriteLine("origin: " & noteDimOrigin.X & ", " & noteDimOrigin.Y)
	letterPref = noteDim.GetLetteringPreferences()
	letterangle = letterPref.Angle
	dimpref = noteDim.GetDimensionPreferences()
	dimangle = dimpref.TextOrienationAngle
	'symbolPref = NXOpen.Preferences.AnnotationPreferences.GetSymbolPreferences()
	symbolPref = theAnnotationManager.Preferences.GetSymbolPreferences()
	'lw.WriteLine("Alignment Position: " & letterPref.AlignmentPosition.ToString())
	'lw.WriteLine("ID Symbol size: " & symbolPref.IDSymbolSize)
	'lw.WriteLine("Annotation type: " & noteDim.GetType().ToString())

	
	Dim nullAnnotations_IdSymbol As Annotations.IdSymbol = Nothing
	Dim idSymbolBuilder1 As Annotations.IdSymbolBuilder
	
	idSymbolBuilder1 = workPart.Annotations.IdSymbols.CreateIdSymbolBuilder(nullAnnotations_IdSymbol)
	idSymbolBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
	idSymbolBuilder1.Type = Annotations.IdSymbolBuilder.SymbolTypes.Circle
	idSymbolBuilder1.UpperText = noteNumber
	'use the symbol size set in the part
	idSymbolBuilder1.Size = 4
	idSymbolBuilder1.Style.LetteringStyle.GeneralTextSize = 2.5
	idSymbolBuilder1.Style.LetteringStyle.Angle = dimangle
	
	Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData
	Dim nullPoint As Point = Nothing
	Dim nullView As View = Nothing
	With assocOrigin1
		.OriginType = Annotations.AssociativeOriginType.OffsetFromText
		.OffsetAnnotation = noteDim
		.OffsetAlignmentPosition = Annotations.AlignmentPosition.TopRight
		.AssociatedPoint = nullPoint
		.StackAlignmentPosition = Annotations.StackAlignmentPosition.Above
		.AlignedAnnotation = Nothing
		if noteDim.GetType().ToString() = "NXOpen.Annotations.Note" Then
			.XOffsetFactor = XOffsetNote
			.YOffsetFactor = YOffsetNote
		Else
			.XOffsetFactor = XOffsetDim
			.YOffsetFactor = YOffsetDim
		End if
	End With
	Dim point1 As Point3d = New Point3d(noteDimOrigin.X-4, noteDimOrigin.Y+6, 0.0)
	'idSymbolBuilder1.Origin.SetInferRelativeToGeometry(True)
	'idSymbolBuilder1.Origin.SetAssociativeOrigin(assocOrigin1)
	idSymbolBuilder1.Origin.Origin.SetValue(Nothing, nullView, point1)
	
	Dim QC_IDSymbol As IDSymbol
	QC_IDSymbol = idSymbolBuilder1.Commit()
	'change IDSymbol layer to match that of the dimension or note it is attached to
	QC_IDSymbol.Layer = 109
	idSymbolBuilder1.Destroy()
	
	noteNumber += 1
	
End While
lw.Close
theSession.SetUndoMarkName(markId1, "Label Dimensions")
theSession.SetUndoMarkVisibility(markId1, Nothing, Session.MarkVisibility.Visible)		

End Sub 'Main

'**************************************************
    Function selectNoteDimension(ByVal prompt As String, ByRef obj As Annotation)
	'Annotation class covers dimensions and notes
	'Annotation -> Dimension
	'Annotation -> DraftingAid -> SimpleDraftingAid -> NoteBase -> BaseNote -> Note
        Dim ui As UI = GetUI()
        Dim mask(1) As Selection.MaskTriple
        With mask(0)
            .Type = UFConstants.UF_dimension_type
            .Subtype = 0
            .SolidBodySubtype = 0
        End With
		With mask(1)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_note_subtype
            .SolidBodySubtype = 0
        End With
		
        Dim cursor As Point3d = Nothing

        Dim resp As Selection.Response = _
        ui.SelectionManager.SelectObject(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	'selectNoteDimension
'**************************************************

End Module 

Can anyone help me on this problem?

Thanks
CSchnei

RE: nx journal to create Index number at dimension with adjusted orientation

Not guaranteed to solve all your problems, but should get you past your current hurdle:

CODE

'journal to Create Non- Associative Index Numbers at Dimensions or Notes

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


Module Module18
    Sub Main()

        '*************************************************************************
        'change the following offset distances to get something that works for you
        'offsets from dimension text
        Const XOffsetDim As Double = 0
        Const YOffsetDim As Double = 2
        'offsets from notes
        Const XOffsetNote As Double = -3
        Const YOffsetNote As Double = 0
        '*************************************************************************

        Dim theSession As Session = Session.GetSession()
        Dim workPart As Part = theSession.Parts.Work
        Dim displayPart As Part = theSession.Parts.Display
        Dim lw As ListingWindow = theSession.ListingWindow
        Dim noteDim As Annotation
        Dim noteDimOrigin As Point3d = Nothing
        Dim letterPref As LetteringPreferences = Nothing
        Dim symbolPref As SymbolPreferences = Nothing
        Dim dimpref As DimensionPreferences = Nothing
        Dim noteNumber As Integer
        Dim letterangle As Double
        Dim dimangle As Double
        Dim input As String
        Dim theAnnotationManager As NXOpen.Annotations.AnnotationManager = workPart.Annotations
        Dim idTextAngle As Double

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

        Do
            input = InputBox("Enter starting INDEX number: ", "Create Index Numbers at Dimensions or Notes", "")
        Loop Until (IsNumeric(input))
        noteNumber = input

        lw.Open()

        While selectNoteDimension("Select Dimension or Note", noteDim) = Selection.Response.Ok

            If TypeOf (noteDim) Is Annotations.Note Then
                'code for notes
                'lw.WriteLine("note: " & noteDim.GetType.ToString)
                letterPref = noteDim.GetLetteringPreferences()
                letterangle = letterPref.Angle
                idTextAngle = letterangle

            Else
                'code for dims
                'lw.WriteLine("dim: " & noteDim.GetType.ToString)
                Dim theDim As Dimension = noteDim
                dimpref = theDim.GetDimensionPreferences()
                dimangle = dimpref.TextOrienationAngle
                idTextAngle = dimangle

            End If

            noteDimOrigin = noteDim.AnnotationOrigin
            'lw.WriteLine("origin: " & noteDimOrigin.X & ", " & noteDimOrigin.Y)
            'symbolPref = NXOpen.Preferences.AnnotationPreferences.GetSymbolPreferences()
            symbolPref = theAnnotationManager.Preferences.GetSymbolPreferences()
            'lw.WriteLine("Alignment Position: " & letterPref.AlignmentPosition.ToString())
            'lw.WriteLine("ID Symbol size: " & symbolPref.IDSymbolSize)
            'lw.WriteLine("Annotation type: " & noteDim.GetType().ToString())


            Dim nullAnnotations_IdSymbol As Annotations.IdSymbol = Nothing
            Dim idSymbolBuilder1 As Annotations.IdSymbolBuilder

            idSymbolBuilder1 = workPart.Annotations.IdSymbols.CreateIdSymbolBuilder(nullAnnotations_IdSymbol)
            idSymbolBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
            idSymbolBuilder1.Type = Annotations.IdSymbolBuilder.SymbolTypes.Circle
            idSymbolBuilder1.UpperText = noteNumber
            'use the symbol size set in the part
            idSymbolBuilder1.Size = 4
            idSymbolBuilder1.Style.LetteringStyle.GeneralTextSize = 2.5
            idSymbolBuilder1.Style.LetteringStyle.Angle = idTextAngle

            Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData
            Dim nullPoint As Point = Nothing
            Dim nullView As View = Nothing
            With assocOrigin1
                .OriginType = Annotations.AssociativeOriginType.OffsetFromText
                .OffsetAnnotation = noteDim
                .OffsetAlignmentPosition = Annotations.AlignmentPosition.TopRight
                .AssociatedPoint = nullPoint
                .StackAlignmentPosition = Annotations.StackAlignmentPosition.Above
                .AlignedAnnotation = Nothing
                If noteDim.GetType().ToString() = "NXOpen.Annotations.Note" Then
                    .XOffsetFactor = XOffsetNote
                    .YOffsetFactor = YOffsetNote
                Else
                    .XOffsetFactor = XOffsetDim
                    .YOffsetFactor = YOffsetDim
                End If
            End With
            Dim point1 As Point3d = New Point3d(noteDimOrigin.X - 4, noteDimOrigin.Y + 6, 0.0)
            'idSymbolBuilder1.Origin.SetInferRelativeToGeometry(True)
            'idSymbolBuilder1.Origin.SetAssociativeOrigin(assocOrigin1)
            idSymbolBuilder1.Origin.Origin.SetValue(Nothing, nullView, point1)

            Dim QC_IDSymbol As IdSymbol
            QC_IDSymbol = idSymbolBuilder1.Commit()
            'change IDSymbol layer to match that of the dimension or note it is attached to
            QC_IDSymbol.Layer = 109
            idSymbolBuilder1.Destroy()

            noteNumber += 1

        End While
        lw.Close()
        theSession.SetUndoMarkName(markId1, "Label Dimensions")
        theSession.SetUndoMarkVisibility(markId1, Nothing, Session.MarkVisibility.Visible)

    End Sub 'Main

    '**************************************************
    Function selectNoteDimension(ByVal prompt As String, ByRef obj As Annotation)
        'Annotation class covers dimensions and notes
        'Annotation -> Dimension
        'Annotation -> DraftingAid -> SimpleDraftingAid -> NoteBase -> BaseNote -> Note
        Dim ui As UI = GetUI()
        Dim mask(1) As Selection.MaskTriple
        With mask(0)
            .Type = UFConstants.UF_dimension_type
            .Subtype = 0
            .SolidBodySubtype = 0
        End With
        With mask(1)
            .Type = UFConstants.UF_drafting_entity_type
            .Subtype = UFConstants.UF_draft_note_subtype
            .SolidBodySubtype = 0
        End With

        Dim cursor As Point3d = Nothing

        Dim resp As Selection.Response = _
        ui.SelectionManager.SelectObject(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    'selectNoteDimension
    '**************************************************

End Module 

www.nxjournaling.com

RE: nx journal to create Index number at dimension with adjusted orientation

(OP)
That's exactly what I need, thanks a lot.
cschnei

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources