Inventor Customization

Reply
Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 11 of 19 (150 Views)

Re: Trying to use "GetPromptTextValues" method

01-08-2013 01:06 PM in reply to: dave.deane

Hello

 

I see the video, but can't believe what I see. I'm using the same code (with removed i=i+1, that's correct in your code), open a new Inventor-dwg, insert block "BRA" from your template file, fill out some attributes, run the code and get attributes and values. Please see attached Screenshots in zipfile.

I'm using Inventor 2013 SP1.1 Update 1.

 

Sorry, I'm running out of ideas what's going wrong.

Valued Contributor
dave.deane
Posts: 78
Registered: ‎04-27-2007
Message 12 of 19 (141 Views)

Re: Trying to use "GetPromptTextValues" method

01-09-2013 11:28 AM in reply to: krieg

I am using Inventor Professional 2013 sp1.1 64 bit xp pro

I also have Inventor 2013 sp1.1 (non professional) on 32 bit xp pro. It doesn't work on either.

In your code did you have sTags dim as strings or objects? Any chance you can upload the .exe to see if your working build works on this end?

 

A support case has been logged at Autodesk. Hopefully, I will get this sorted out.

 

Thank you again,

Dave

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 13 of 19 (137 Views)

Re: Trying to use "GetPromptTextValues" method

01-09-2013 01:20 PM in reply to: dave.deane

Hello

 

sTags and sValues are defined as String. I have counted the attributes and found 23. So:

 

Dim sTags(23) As String
Dim sAttr(23) As String

 I attached the exe and if this works on your site, I can send you my project. Maybe there's a difference we both don't registred yet.

 

Please replace the extension txt with exe.

Valued Contributor
dave.deane
Posts: 78
Registered: ‎04-27-2007
Message 14 of 19 (133 Views)

Re: Trying to use "GetPromptTextValues" method

01-09-2013 01:34 PM in reply to: krieg

It doesn't work. I get an array error, screenshot below.

I hope autodesk support can save me on this one. I don't know what else to do.

 

 

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 15 of 19 (127 Views)

Re: Trying to use "GetPromptTextValues" method

01-09-2013 01:40 PM in reply to: dave.deane

Hello

 

Sorry couldn't help you. My best wishes Autodesk can help.

ADN Support Specialist
xiaodong.liang
Posts: 1,262
Registered: ‎06-12-2011
Message 16 of 19 (121 Views)

Re: Trying to use "GetPromptTextValues" method

01-10-2013 09:52 PM in reply to: dave.deane

I discussed with our engineer and we did some tests. The following code can work. Not much change than the code Krieg provided in message 9. Could you give it a try?

 

 

  PrivateSub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

        ' Connect to a running instance of Inventor. 

        Dim invApp As Inventor.Application

 

        ' Check to see if a drawing is active

        invApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")

        If invApp.ActiveDocument.DocumentType <> Inventor.DocumentTypeEnum.kDrawingDocumentObject Then

            MsgBox("Need to have a drawing document active")

            Return

        EndIf

 

        ' Create ref to active drawing document

        Dim oDrawingDoc As Inventor.DrawingDocument

        oDrawingDoc = invApp.ActiveDocument

 

        ' Create ref to AutoCADBlocks collection in the active sheet

        Dim cAcadBlocks As Inventor.AutoCADBlocks

        cAcadBlocks = oDrawingDoc.ActiveSheet.AutoCADBlocks

 

        ' Set the name of the block

        Dim AcadBlockName AsString

        AcadBlockName = "BRA"

 

        ' Create ref to the AutoCAD block object in the active sheet

        Dim oAcadBlock As Inventor.AutoCADBlock

        oAcadBlock = cAcadBlocks.Item(AcadBlockName)

 

        ' check to see if block object code is working (it does)

        Debug.Print(oAcadBlock.Scale)

        Debug.Print(oAcadBlock.LineWeight)

        Debug.Print(oAcadBlock.Name)

        Debug.Print(oAcadBlock.AttributeSets.Count)

 

 

        'XXXXXXXXXXXXXXXXXXXX FAILS BELOW XXXXXXXXXXXXXXXXXXXXX

        ' Try and display block tags and values

 

        'correct

        Dim sTags() AsString = NewString() {}

        Dim sAttr() AsString = NewString() {}

 

 

        'wrong

        'Dim sTags() As String = New Object() {}

        'Dim sAttr() As String = New Object() {}

 

        'correct only when  the count of texts

        ' are no more than 23

        'Dim sTags(23) As String

        'Dim sAttr(23) As String

 

        'wrong

        'Dim sTags() As String

        'Dim sAttr() As String

 

 

 

        oAcadBlock.GetPromptTextValues(sTags, sAttr)

 

        Dim i AsInteger

        Dim iCount AsInteger

        iCount = UBound(sTags)

        Debug.Print("icount = " & iCount)

 

        ' display attribute tag and value

        For i = 0 To iCount

            MsgBox(sTags(i) & " = " & sAttr(i))

            i = i + 1

        Next

 

    EndSub



Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

Valued Contributor
dave.deane
Posts: 78
Registered: ‎04-27-2007
Message 17 of 19 (111 Views)

Re: Trying to use "GetPromptTextValues" method

01-11-2013 05:57 AM in reply to: xiaodong.liang

Xiaodong,

It will not build as posted. Intellisense does not like AsString, Once I separate the words it then doesn't like the empty squiggly brackets at the end. Please see screen shot below.

Mentor
krieg
Posts: 176
Registered: ‎11-22-2009
Message 18 of 19 (101 Views)

Re: Trying to use "GetPromptTextValues" method

01-11-2013 02:31 PM in reply to: dave.deane

Hello

 

Try it in this way

 

Dim sTags() As String = New System.String() {}

 

Valued Contributor
dave.deane
Posts: 78
Registered: ‎04-27-2007
Message 19 of 19 (95 Views)

Re: Trying to use "GetPromptTextValues" method

01-14-2013 06:58 AM in reply to: krieg

Winner, Winner! ....... It builds and works! Thank you Krieg and Xiadong.

 

Is this just part of the learning curve or is there some reading references I need to study? I'm not sure how I would have ever figured this out. I can't find any meaningful syntax explantion searching the web for this. What purpose does the "{}" do? I'm just wondering out loud why a "regular" string array does not work for me but it did for you Krieg?

 

Onward with the rest of my program development.

 

Thank you again,

Dave

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