SOS-----iLogic: Export Parts List error

SOS-----iLogic: Export Parts List error

Anonymous
Not applicable
941 Views
13 Replies
Message 1 of 14

SOS-----iLogic: Export Parts List error

Anonymous
Not applicable

 

-------------------------------------

 

http://inventortrenches.blogspot.com/2011/06/ilogic-export-parts-list-with-options.html

-------------------------------------

我按照这里的源码创建的iLogic,

Smiley Happy

WIN7 64bit

Excel 2013

正常运行

 

Smiley Sad

在WIN10 64bit

Excel 2013

无法运行提示错误

System.ArgumentException: 参数错误。 (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
在 Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)
在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, Boolean IgnoreReturn)
在 ThisRule.Main()
在 Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
在 iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

0 Likes
Accepted solutions (4)
942 Views
13 Replies
Replies (13)
Message 2 of 14

rhasell
Advisor
Advisor

Hi

 

There is not much to go on, but historically, there are few things that can catch you out, and if these conditions are not met, then an error will be generated, or the code will fail.

 

Have a look at the screen cap, your parts list needs to match the export options, visa versa, change the code to suit your parts list. (But before you can customize it, you must get it working exactly the same as Curtis's example)

Also you need the template file as shown. 

 

Good luck.

 

sos-ilogic.JPG

Reg
2026.1
Message 3 of 14

Anonymous
Not applicable

你好,同样的代码我在家里的电脑正常运行&输出,到公司的WIN10 企业版却提示这个错误。

 

'get the path and name of the drawing file
path_and_name = ThisDoc.PathAndFileName(False) ' without extension

'check for existing XLS file and delete it if found
If Dir(path_and_name & ".xls") <> "" Then
Kill(path_and_name & ".xls")
Else
End If

'define oDoc
oDoc = ThisDoc.Document

'specify the drawing sheet
'oSheet = oDoc.Sheets("Sheet:1") ' sheet by name
oSheet = oDoc.Sheets(1) ' first sheet

' say there is a Partslist on the sheet.
oPartslist = oSheet.PartsLists(1)

' create a new NameValueMap object
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
'输出选项
'设置模板
oOptions.Value("Template") = "E:\ZY\BOM.xlsx"
'表格名称
oOptions.Value("TableName") = “”
'输出列选择
oOptions.Value("ExportedColumns") = "ZY_2;ZY_1"
'开始单元
oOptions.Value("StartingCell") = "F1"

'应用单元格式
oOptions.Value("ApplyCellFormatting") = False
'反向输出
oOptions.Value("IncludeHeading") = False
'自动调整列宽
oOptions.Value("AutoFitColumnWidth") = True
'包括标题
oOptions.Value("IncludeTitle") = False

' export the Partslist to Excel with options
oPartslist.Export(path_and_name & ".xls", PartsListFileFormatEnum.kMicrosoftExcel, oOptions)

Shell("explorer.exe " & ThisDoc.Path & "\", vbNormalFocus)

'-------------End of ilogic ------------------------------

0 Likes
Message 4 of 14

Anonymous
Not applicable

我解决不了,已经贴了源码,请帮我分析下原因

0 Likes
Message 5 of 14

rhasell
Advisor
Advisor

Hi

 

Please try and match the example before you customize it. (Does the example work correctly?)

Without seeing the template and the Parts list, I am unable to troubleshoot it.

- Remove the kill command for now

- Ensure that the Column headers match.

- Ensure that the Part List counter is correct - EG if you have more than one.

- The Table name is blank, try leave it out.

 

I don't use this code or anything similar, so I don't have a working environment to compare to.

 

 

Reg
2026.1
0 Likes
Message 6 of 14

Anonymous
Not applicable

你好,我将模板&文件分享,谢谢!

0 Likes
Message 7 of 14

rhasell
Advisor
Advisor
Accepted solution

Hi

 

Thanks. I am unable to open you drawing, as I have not installed 2019 yet. ( opened the assembly, but cant do anything with it)

But the first thing I notice, is your code calls for "BOM.xlsx" and the file you sent me is "BOM.xls"

 

Maybe its that simple?

 

 

Reg
2026.1
Message 8 of 14

Anonymous
Not applicable

也许是这样,非常感谢了Smiley Happy

 

Message 9 of 14

rhasell
Advisor
Advisor
Accepted solution

Hi

No worries, glad I could help. (沒有憂慮,很高興我能幫上忙。)

 

I hope you get it working.

 

Reg
2026.1
0 Likes
Message 10 of 14

Anonymous
Not applicable

我遇见这个问题,是因为字符的原因?

 

无标题.png

0 Likes
Message 11 of 14

Yijiang.Cai
Autodesk
Autodesk
Accepted solution

@Anonymous,

请问这个问题已经解决了吗?

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com
Message 12 of 14

rhasell
Advisor
Advisor
Accepted solution

Do the columns appear in your parts list in that exact order, and with the exact name?

"PART NUMBER;ZY_8;QTY"

 

I Have just tested the example and it worked 100% for me.

I Managed to get it to fail, by putting a Column header in that was not part of my Parts List. (In my case "PART NUMBER" , I don't use it in my Parts List.)

So I am guessing it is simple heading issue, or typo.

 

Reg
2026.1
Message 13 of 14

Anonymous
Not applicable

嗯是标题问题,我已经换成中文一切正常,谢谢了Smiley LOL

Message 14 of 14

Yijiang.Cai
Autodesk
Autodesk

解决问题就好了,谢谢你的反馈

Thanks,
River Cai

Inventor Quality Assurance Team
Autodesk, Inc.
Email: River-Yijiang.Cai@autodesk.com