Inventor Customization

Reply
Active Contributor
shirazbj
Posts: 46
Registered: ‎02-25-2007
Message 1 of 3 (808 Views)

how to create a sketched symbol with prompted text in vb.net?

808 Views, 2 Replies
02-04-2013 09:33 PM

Hi,

 

Usually I use the TextBoxes. But its text would not change.

 

How to use vb.net to add a prompted text into the definition of a sketched symbol?

 

Regards,

 

Peter

ADN Support Specialist
philippe.leefsma
Posts: 562
Registered: ‎06-02-2009
Message 2 of 3 (799 Views)

Re: how to create a sketched symbol with prompted text in vb.net?

02-05-2013 08:09 AM in reply to: shirazbj

Hi Peter,

 

There is a sample that does that from the Help Files, see SketchedSymbolDefinition Interface:

 

Public Sub CreateSketchedSymbolDefinition()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    ' Create the new sketched symbol definition.
    Dim oSketchedSymbolDef As SketchedSymbolDefinition
    Set oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Add("Circular Callout")

    ' Open the sketched symbol definition's sketch for edit. This is done by calling the Edit
    ' method of the SketchedSymbolDefinition to obtain a DrawingSketch. This actually creates
    ' a copy of the sketched symbol definition's and opens it for edit.
    Dim oSketch As DrawingSketch
    Call oSketchedSymbolDef.Edit(oSketch)

    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    ' Use the functionality of the sketch to add sketched symbol graphics.
    Dim oSketchLine As SketchLine
    Set oSketchLine = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(0, 0), oTG.CreatePoint2d(20, 0))

    Dim oSketchCircle As SketchCircle
    Set oSketchCircle = oSketch.SketchCircles.AddByCenterRadius(oTG.CreatePoint2d(22, 0), 2)

    Call oSketch.GeometricConstraints.AddCoincident(oSketchLine.EndSketchPoint, oSketchCircle)

    ' Make the starting point of the sketch line the insertion point
    oSketchLine.StartSketchPoint.InsertionPoint = True

    ' Add a prompted text field at the center of the sketch circle.
    Dim sText As String
    sText = "<Prompt>Enter text 1</Prompt>"
    Dim oTextBox As TextBox
    Set oTextBox = oSketch.TextBoxes.AddFitted(oTG.CreatePoint2d(22, 0), sText)
    oTextBox.VerticalJustification = kAlignTextMiddle
    oTextBox.HorizontalJustification = kAlignTextCenter

    Call oSketchedSymbolDef.ExitEdit(True)
End Sub

Public Sub InsertSketchedSymbolOnSheet()
    ' Set a reference to the drawing document.
    ' This assumes a drawing document is active.
    Dim oDrawDoc As DrawingDocument
    Set oDrawDoc = ThisApplication.ActiveDocument

    ' Obtain a reference to the desired sketched symbol definition.
    Dim oSketchedSymbolDef As SketchedSymbolDefinition
    Set oSketchedSymbolDef = oDrawDoc.SketchedSymbolDefinitions.Item("Circular Callout")

    Dim oSheet As Sheet
    Set oSheet = oDrawDoc.ActiveSheet

    ' This sketched symbol definition contains one prompted string input. An array
    ' must be input that contains the strings for the prompted strings.
    Dim sPromptStrings(0) As String
    sPromptStrings(0) = "A"

    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    ' Add an instance of the sketched symbol definition to the sheet.
    ' Rotate the instance by 45 degrees and scale by .75 when adding.
    ' The symbol will be inserted at (0,0) on the sheet. Since the
    ' start point of the line was marked as the insertion point, the
    ' start point should end up at (0,0).
    Dim oSketchedSymbol As SketchedSymbol
    Set oSketchedSymbol = oSheet.SketchedSymbols.Add(oSketchedSymbolDef, oTG.CreatePoint2d(0, 0), (3.14159 / 4), 0.75, sPromptStrings)
End Sub

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Active Contributor
shirazbj
Posts: 46
Registered: ‎02-25-2007
Message 3 of 3 (793 Views)

Re: how to create a sketched symbol with prompted text in vb.net?

02-05-2013 04:09 PM in reply to: shirazbj

Hi Philippe,

 

<Prompt>, so easy.

 

Thanks very much.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube