Sign in to follow this  
Followers 0
Vans21

array difference autoit vs. vb

3 posts in this topic

I am trying to use Autoit to automate cad software.

Currently I am having troubles with an array input.

This is the Syntax from the programs help file

Sheet.AddTitleBlock( TitleBlockDefinition As Variant, [TitleBlockLocation] As Variant, [PromptStrings] As Variant )

Paramters

[PromptStrings] - Optional input array of Strings that specifies the input strings to use as input for prompted text fields that my be present in the title block definition. If prompted strings exist in the title block definition you must supply input strings through this argument or this method will fail. The prompt strings and their order are obtained by querying the TextBox objects in the TitleBlockDefinition. The order they're returned by the TextBoxes collection is the same order the input strings need to be supplied in the PromptStrings array.

Testing using vb.net the following array string works

Dim sPromptStrings(4) As String

    sPromptStrings(0) = "1"

    sPromptStrings(1) = "1"

    sPromptStrings(2) = "1:1"

    sPromptStrings(3) = "test"

    sPromptStrings(4) = "test"

But using Autoit array string it does not

Dim $sPromptStrings[5]

    $sPromptStrings[0] = "1"

    $sPromptStrings[1] = "1"

    $sPromptStrings[2] = "1:1"

    $sPromptStrings[3] = "test"

    $sPromptStrings[4] = "test"

Can anyone shed some light on why this is not working?

Share this post


Link to post
Share on other sites



Vans21,

Show the script and the error message, please.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Dim $oInv = ObjGet("", "Inventor.Application") ; Get an existing Inventor Object
If @error Then
Dim $oInv = ObjCreate("Inventor.Application") ; Create an Inventor Object
If @error Then

MsgBox(1, "Error", "Error couldn't start inventor")
EndIf
EndIf
If IsObj($oInv) Then
$oInv.SilentOperation = True
$oInv.Documents.Open("My Dir Loc", True)

Dim $oDoc = $oInv.ActiveDocument

$oDoc.Sheets.Add(9994, 10241, "My Sheet Name")
$oSheet = $oDoc.ActiveSheet
Dim $oBorder = $oDoc.BorderDefinitions.Item("My Border Name")
$oSheet.AddBorder($oBorder)
Dim $oTitle = $oDoc.TitleBlockDefinitions.Item("My Title Name")

Dim $sPromptStrings[5]
$sPromptStrings[0] = "1"
$sPromptStrings[1] = "1"
$sPromptStrings[2] = "1:1"
$sPromptStrings[3] = "test"
$sPromptStrings[4] = "test"

$oTitleBlock = $oSheet.AddTitleBlock($oTitle, 29444, $sPromptStrings)

Else
MsgBox(1, "Error", "Error couldn't start inventor not a com object")
EndIf

--> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop

Z:AutoItDesignsMacrosNEWREVtest.au3 (29) : ==> The requested action with this object has failed.:

$oTitleBlock = $oSheet.AddTitleBlock($oTitle, 29444, $sPromptStrings)

$oTitleBlock = $oSheet.AddTitleBlock($oTitle, 29444, $sPromptStrings)^ ERROR

->12:19:47 AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 2.913

This is the code that worked in vb.net

Dim sPromptStrings(4) As String
     sPromptStrings(0) = "1"
     sPromptStrings(1) = "1"
     sPromptStrings(2) = "1:1"
     sPromptStrings(3) = "test"
     sPromptStrings(4) = "test"
Dim oTitleBlock As Inventor.TitleBlock
oTitleBlock = oSheet.AddTitleBlock(oTitle, 29444, sPromptStrings)
Edited by Vans21

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0