Text on IPT Part

Text on IPT Part

isocam
Collaborator Collaborator
356 Views
1 Reply
Message 1 of 2

Text on IPT Part

isocam
Collaborator
Collaborator

I have the following function in a Inventor vba module, but I cannot get it to work. What is wrong?

 

CAN ANYBODY HELP??

 

  Public Function GetPartText(Doc As PartDocument, sketch As PlanarSketch, ProcType As Integer) As Boolean
        Dim tb As Textbox
       
        For Each tb In tb.Text
            MsgBox (tb.Text)
            MsgBox (tb.Rotation)
            MsgBox (tb.Style.FontSize)
            MsgBox (tb.Origin.x / 2.54)
        Next
    End Function

 

Many thanks in advance!

0 Likes
357 Views
1 Reply
Reply (1)
Message 2 of 2

Mike.Wohletz
Collaborator
Collaborator

You are almost on the right track with that one, but your code is trying to loop the object that you have just created and that is not going to work. I have attached a couple of samples that I think will work. I have not tested this but I am almost sure that it is correct..

 

    Public Sub callGetPartText()
        If G_oApp.ActiveEditDocument.DocumentType = DocumentTypeEnum.kPartDocumentObject Then
            ' this will list the text box  in the last sketch
            GetPartText(G_oApp.ActiveEditDocument)

            'this will get the text box from the first sketch

            Dim oDoc As PartDocument = G_oApp.ActiveEditDocument
            Dim oCompDef As PartComponentDefinition = oDoc.ComponentDefinition
            MsgBox(GetPartText1(oCompDef.Sketches.Item(1)))
        End If
    End Sub

    Public Function GetPartText(ByVal Doc As PartDocument) As Boolean
        Dim oCompDef As PartComponentDefinition = Doc.ComponentDefinition
        Dim oSketch As PlanarSketch = oCompDef.Sketches.Item(oCompDef.Sketches.Count) ' this will get the last sketch
        For Each tb As TextBox In oSketch.TextBoxes
            MsgBox(tb.Text & vbCrLf & tb.Rotation & vbCrLf & tb.Style.FontSize & vbCrLf & tb.Origin.X / 2.54)
        Next
    End Function

    Public Function GetPartText1(ByVal oSketch As PlanarSketch) As String
        Dim txt As String = Nothing
        For Each tb As TextBox In oSketch.TextBoxes
            txt = (tb.Text & vbCrLf & tb.Rotation & vbCrLf & tb.Style.FontSize & vbCrLf & tb.Origin.X / 2.54)
        Next
        Return txt
    End Function

 

 

 

0 Likes