×
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

Create Notes, a simple way?

Create Notes, a simple way?

Create Notes, a simple way?

(OP)
Is there is a simply way to create 10, 15, 30...notes using this code lines: (the main concern is to avoid repeating 30 times the same block of lines but with diferent counter (14))

Dim nullAnnotations_SimpleDraftingAid14 As Annotations.SimpleDraftingAid = Nothing

Dim draftingNoteBuilder14 As Annotations.DraftingNoteBuilder
draftingNoteBuilder14 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid14)
draftingNoteBuilder14.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane
draftingNoteBuilder14.Origin.SetInferRelativeToGeometry(False)
draftingNoteBuilder14.Origin.SetInferRelativeToGeometry(True)
draftingNoteBuilder14.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.BottomLeft

Dim text14(0) As String
text14(0) = "Fecha1"

draftingNoteBuilder14.Text.TextBlock.SetText(text14)
draftingNoteBuilder14.Style.LetteringStyle.GeneralTextSize = 1.3129
draftingNoteBuilder14.Style.LetteringStyle.GeneralTextCharSpaceFactor = 0.8945
draftingNoteBuilder14.Style.LetteringStyle.GeneralTextAspectRatio = 0.8945
draftingNoteBuilder14.Style.LetteringStyle.GeneralTextColor = workPart.Colors.Find("Black")
draftingNoteBuilder14.Style.LetteringStyle.GeneralTextFont = 2

Dim fontIndex14 As Integer
fontIndex14 = workPart.Fonts.AddFont("ge_font5")

Dim assocOrigin14 As Annotations.Annotation.AssociativeOriginData
assocOrigin14.OriginType = Annotations.AssociativeOriginType.Drag

Dim nullView14 As View = Nothing
assocOrigin14.View = nullView14
assocOrigin14.ViewOfGeometry = nullView14

Dim nullPoint14 As Point = Nothing
assocOrigin14.PointOnGeometry = nullPoint14
assocOrigin14.VertAnnotation = Nothing
assocOrigin14.VertAlignmentPosition = Annotations.AlignmentPosition.TopLeft
assocOrigin14.HorizAnnotation = Nothing
assocOrigin14.HorizAlignmentPosition = Annotations.AlignmentPosition.TopLeft
assocOrigin14.AlignedAnnotation = Nothing
assocOrigin14.DimensionLine = 0
assocOrigin14.AssociatedView = nullView14
assocOrigin14.AssociatedPoint = nullPoint14
assocOrigin14.OffsetAnnotation = Nothing
assocOrigin14.OffsetAlignmentPosition = Annotations.AlignmentPosition.TopLeft
assocOrigin14.XOffsetFactor = 0.0
assocOrigin14.YOffsetFactor = 0.0
assocOrigin14.StackAlignmentPosition = Annotations.StackAlignmentPosition.Above
draftingNoteBuilder14.Origin.SetAssociativeOrigin(assocOrigin14)

Dim point14 As Point3d = New Point3d(92, 26, 0.0)
draftingNoteBuilder14.Origin.Origin.SetValue(Nothing, nullView14, point14)
draftingNoteBuilder14.Origin.SetInferRelativeToGeometry(True)

Dim nXObject14 As NXObject
nXObject14 = draftingNoteBuilder14.Commit()
draftingNoteBuilder14.Destroy()

Is possible that some lines are missing but the code works.

Regards

RE: Create Notes, a simple way?

Take that chunk of code and turn it into a subroutine or function that you can call multiple times from Sub Main.

Here's a function example that takes the note text, x coordinate, and y coordinate as parameters:

CODE

Option Strict Off  
Imports System  
Imports NXOpen  

Module Module1  

    Dim theSession As Session = Session.GetSession()  
    Dim workPart As Part = theSession.Parts.Work  

    Sub Main()  

        Dim myNotes(9) As NXObject  
        Dim i As Integer = 0  

        For i = 0 To 9  
            myNotes(i) = AddNote("Note number: " & i.ToString, i, i)  
        Next  

    End Sub  

    Function AddNote(ByVal noteText As String, ByVal Xposition As Double, ByVal Yposition As Double) As NXObject  

        Dim nullAnnotations_SimpleDraftingAid1 As Annotations.SimpleDraftingAid = Nothing  

        Dim draftingNoteBuilder1 As Annotations.DraftingNoteBuilder  
        draftingNoteBuilder1 = workPart.Annotations.CreateDraftingNoteBuilder(nullAnnotations_SimpleDraftingAid1)  
        draftingNoteBuilder1.Origin.Plane.PlaneMethod = Annotations.PlaneBuilder.PlaneMethodType.XyPlane  
        draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(False)  
        draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)  
        draftingNoteBuilder1.Origin.Anchor = Annotations.OriginBuilder.AlignmentPosition.BottomLeft  

        Dim text14(0) As String  
        text14(0) = noteText  

        draftingNoteBuilder1.Text.TextBlock.SetText(text14)  
        draftingNoteBuilder1.Style.LetteringStyle.GeneralTextSize = 1.3129  
        draftingNoteBuilder1.Style.LetteringStyle.GeneralTextCharSpaceFactor = 0.8945  
        draftingNoteBuilder1.Style.LetteringStyle.GeneralTextAspectRatio = 0.8945  
        draftingNoteBuilder1.Style.LetteringStyle.GeneralTextColor = workPart.Colors.Find("Black")  
        draftingNoteBuilder1.Style.LetteringStyle.GeneralTextFont = 2  

        Dim fontIndex1 As Integer  
        fontIndex1 = workPart.Fonts.AddFont("ge_font5")  

        Dim assocOrigin1 As Annotations.Annotation.AssociativeOriginData  
        assocOrigin1.OriginType = Annotations.AssociativeOriginType.Drag  

        Dim nullView1 As View = Nothing  
        assocOrigin1.View = nullView1  
        assocOrigin1.ViewOfGeometry = nullView1  

        Dim nullPoint1 As Point = Nothing  
        assocOrigin1.PointOnGeometry = nullPoint1  
        assocOrigin1.VertAnnotation = Nothing  
        assocOrigin1.VertAlignmentPosition = Annotations.AlignmentPosition.TopLeft  
        assocOrigin1.HorizAnnotation = Nothing  
        assocOrigin1.HorizAlignmentPosition = Annotations.AlignmentPosition.TopLeft  
        assocOrigin1.AlignedAnnotation = Nothing  
        assocOrigin1.DimensionLine = 0  
        assocOrigin1.AssociatedView = nullView1  
        assocOrigin1.AssociatedPoint = nullPoint1  
        assocOrigin1.OffsetAnnotation = Nothing  
        assocOrigin1.OffsetAlignmentPosition = Annotations.AlignmentPosition.TopLeft  
        assocOrigin1.XOffsetFactor = 0.0  
        assocOrigin1.YOffsetFactor = 0.0  
        assocOrigin1.StackAlignmentPosition = Annotations.StackAlignmentPosition.Above  
        draftingNoteBuilder1.Origin.SetAssociativeOrigin(assocOrigin1)  

        Dim point1 As Point3d = New Point3d(Xposition, Yposition, 0.0)  
        draftingNoteBuilder1.Origin.Origin.SetValue(Nothing, nullView1, point1)  
        draftingNoteBuilder1.Origin.SetInferRelativeToGeometry(True)  

        Dim nXObject1 As NXObject  
        nXObject1 = draftingNoteBuilder1.Commit()  
        draftingNoteBuilder1.Destroy()  

        Return nXObject1  

    End Function  

    Public Function GetUnloadOption(ByVal dummy As String) As Integer  

        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination  

    End Function  

End Module 

www.nxjournaling.com

RE: Create Notes, a simple way?

(OP)
Thanks cowski, this is great but how could be adapted when the notes have different X and Y positions and style?

RE: Create Notes, a simple way?

The function takes X and Y positions as parameters, pass in whatever you want for each note. Any other text properties that you want to control (text height, font, etc) can be turned into parameters similar to what was done for the noteText, Xposition, and Yposition.

www.nxjournaling.com

RE: Create Notes, a simple way?

(OP)
Ok, I will work on this, thanks for your help!!

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