Errore Code Insert Sketch Symbol via API

Errore Code Insert Sketch Symbol via API

cisia
Explorer Explorer
779 Views
3 Replies
Message 1 of 4

Errore Code Insert Sketch Symbol via API

cisia
Explorer
Explorer

I have a problem to insert a symbol via API with multiple fields to be filled. The following codes show the same function: the first one with variables set to code and functioning, the second with the variables set via the form, and with an error of "call".


First code (OK):

 

Dim astrPrompts(0 To 7) As String
astrPrompts(0) = "1"
astrPrompts(1) = "2"
astrPrompts(2) = "3"
astrPrompts(3) = "4"
astrPrompts(4) = "5"
astrPrompts(5) = "6"
astrPrompts(6) = "7"
astrPrompts(7) = "8"
Set oSketchedSymbol2 = osheet.SketchedSymbols.Add(oSymDef4, oTG.CreatePoint2d(i2, j2), 0, 1, astrPrompts)

 

 

Second Code (Run-time error '5': Invalid procedure call or argument):

 

Dim astrPrompts(0 To 7) As String
astrPrompts(0) = rugosità_gen.chiuso.Text
astrPrompts(1) = rugosità_gen.grezzo.Text
astrPrompts(2) = rugosità_gen.rug_gen.Text
astrPrompts(3) = rugosità_gen.rug_parz1.Text
astrPrompts(4) = rugosità_gen.rug_parz2.Text
astrPrompts(5) = rugosità_gen.rug_parz3.Text
astrPrompts(6) = rugosità_gen.rug_parz4.Text
astrPrompts(7) = rugosità_gen.rug_parz5.Text
Set oSketchedSymbol2 = osheet.SketchedSymbols.Add(oSymDef4, oTG.CreatePoint2d(i2, j2), 0, 1, astrPrompts)

I think the error is caused by astrpromps. Thank You

 

 

0 Likes
780 Views
3 Replies
Replies (3)
Message 2 of 4

cisia
Explorer
Explorer

Help please...

0 Likes
Message 3 of 4

YuhanZhang
Autodesk
Autodesk

Can you show us the text strings from you form for the astrprompts?



If this solves the problem please click ACCEPT SOLUTION so other people can find it easily.



Rocky Zhang
Inventor API PD
Manufacturing Solutions
Autodesk, Inc.

0 Likes
Message 4 of 4

cisia
Explorer
Explorer

the error is caused by the function sketchedsymbols.add  that not accept variables but only constant.  To avoid the   the error,   with a series of "if-then-else" i transform the variable of the form to a series of costant.

 

new code:

 

Set oSymDef4 = oSymDefs.Item("RUG_GEN")

Dim oSketchedSymbol2 As SketchedSymbol

If rugosità_gen.chiuso.Text = "-" Then a0 = "-"
If rugosità_gen.grezzo.Text = "o" Then a1 = "o"
If rugosità_gen.rug_gen.Text = "12.6" Then a2 = "12.6"
If rugosità_gen.rug_gen.Text = "6.3" Then a2 = "6.3"
If rugosità_gen.rug_gen.Text = "3.2" Then a2 = "3.2"
If rugosità_gen.rug_gen.Text = "1.6" Then a2 = "1.6"
If rugosità_gen.rug_gen.Text = "0.8" Then a2 = "0.8"
If rugosità_gen.rug_gen.Text = "0.4" Then a2 = "0.4"
If rugosità_gen.rug_gen.Text = "0.2" Then a2 = "0.2"
If rugosità_gen.rug_gen.Text = "0.1" Then a2 = "0.1"
If rugosità_gen.rug_parz1 = "12.6" Then a3 = "12.6"
If rugosità_gen.rug_parz1 = "6.3" Then a3 = "6.3"
If rugosità_gen.rug_parz1 = "3.2" Then a3 = "3.2"
If rugosità_gen.rug_parz1 = "1.6" Then a3 = "1.6"
If rugosità_gen.rug_parz1 = "0.8" Then a3 = "0.8"
If rugosità_gen.rug_parz1 = "0.4" Then a3 = "0.4"
If rugosità_gen.rug_parz1 = "0.2" Then a3 = "0.2"
If rugosità_gen.rug_parz1 = "0.1" Then a3 = "0.1"
If rugosità_gen.rug_parz2 = "12.6" Then a4 = "12.6"
If rugosità_gen.rug_parz2 = "6.3" Then a4 = "6.3"
If rugosità_gen.rug_parz2 = "3.2" Then a4 = "3.2"
If rugosità_gen.rug_parz2 = "1.6" Then a4 = "1.6"
If rugosità_gen.rug_parz2 = "0.8" Then a4 = "0.8"
If rugosità_gen.rug_parz2 = "0.4" Then a4 = "0.4"
If rugosità_gen.rug_parz2 = "0.2" Then a4 = "0.2"
If rugosità_gen.rug_parz2 = "0.1" Then a4 = "0.1"
If rugosità_gen.rug_parz3 = "12.6" Then a5 = "12.6"
If rugosità_gen.rug_parz3 = "6.3" Then a5 = "6.3"
If rugosità_gen.rug_parz3 = "3.2" Then a5 = "3.2"
If rugosità_gen.rug_parz3 = "1.6" Then a5 = "1.6"
If rugosità_gen.rug_parz3 = "0.8" Then a5 = "0.8"
If rugosità_gen.rug_parz3 = "0.4" Then a5 = "0.4"
If rugosità_gen.rug_parz3 = "0.2" Then a5 = "0.2"
If rugosità_gen.rug_parz3 = "0.1" Then a5 = "0.1"
If rugosità_gen.rug_parz4 = "12.6" Then a6 = "12.6"
If rugosità_gen.rug_parz4 = "6.3" Then a6 = "6.3"
If rugosità_gen.rug_parz4 = "3.2" Then a6 = "3.2"
If rugosità_gen.rug_parz4 = "1.6" Then a6 = "1.6"
If rugosità_gen.rug_parz4 = "0.8" Then a6 = "0.8"
If rugosità_gen.rug_parz4 = "0.4" Then a6 = "0.4"
If rugosità_gen.rug_parz4 = "0.2" Then a6 = "0.2"
If rugosità_gen.rug_parz4 = "0.1" Then a6 = "0.1"
If rugosità_gen.rug_parz5 = "12.6" Then a7 = "12.6"
If rugosità_gen.rug_parz5 = "6.3" Then a7 = "6.3"
If rugosità_gen.rug_parz5 = "3.2" Then a7 = "3.2"
If rugosità_gen.rug_parz5 = "1.6" Then a7 = "1.6"
If rugosità_gen.rug_parz5 = "0.8" Then a7 = "0.8"
If rugosità_gen.rug_parz5 = "0.4" Then a7 = "0.4"
If rugosità_gen.rug_parz5 = "0.2" Then a7 = "0.2"
If rugosità_gen.rug_parz5 = "0.1" Then a7 = "0.1"

Dim astrPrompts(0 To 7) As String
astrPrompts(0) = a0 'rugosità_gen.chiuso.Text
astrPrompts(1) = a1 'rugosità_gen.grezzo.Text
astrPrompts(2) = a2 'rugosità_gen.rug_gen.Text
astrPrompts(3) = a3 'rugosità_gen.rug_parz1.Text
astrPrompts(4) = a5 'rugosità_gen.rug_parz3.Text
astrPrompts(5) = a6 'rugosità_gen.rug_parz4.Text
astrPrompts(6) = a7 'rugosità_gen.rug_parz5.Text
astrPrompts(7) = a4 'rugosità_gen.rug_parz2.Text
   
   Set oSketchedSymbol2 = osheet.SketchedSymbols.Add(oSymDef4, oTG.CreatePoint2d(i2, j2), 0, 1, astrPrompts)

 

 

 

0 Likes