Misstake

Misstake

martinhoos
Advocate Advocate
510 Views
3 Replies
Message 1 of 4

Misstake

martinhoos
Advocate
Advocate

Hi all,

i try a script written by Curtis Waguespack... it stops with this message:

 

 

System.ArgumentException: Falscher Parameter. (Ausnahme von HRESULT: 0x80070057 (E_INVALIDARG))

bei Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateCall(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack, Boolean IgnoreReturn)

bei LmiRuleScript.Main()

bei Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

bei iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

Here is the script:

 

 

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


'define oDoc
oDoc = ThisDoc.Document


'specify the drawing sheet
oSheet = oDoc.Sheets("Blatt: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


'specify an existing template file 
'to use For formatting colors, fonts, etc
oOptions.Value("Template") = "c:\temp\_Vorlage.xls"
  
'specify the columns to export          
oOptions.Value("ExportedColumns") = "POS;ANZ;MENGE;EINH;BENENNUNG;ARTIKEL NR.;ABMESSUNG/DIN"
  
'specify the start cell
oOptions.Value("StartingCell") = "A10"
  
'specify the XLS tab name
'here the file name is used 
oOptions.Value("TableName") = ThisDoc.FileName(False) 'without extension


'choose to include the parts list title row
'in this example "Ye Old List of Parts" is written to the StartingCell 
oOptions.Value("IncludeTitle") = False          


'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True
        
' export the Partslist to Excel with options
oPartslist.Export(path_and_name & ".xls", _
PartsListFileFormatEnum.kMicrosoftExcel, oOptions)  


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

 

 

What is wrong? Thank you for your help!

 

Regards Martin

 

 

 

0 Likes
Accepted solutions (1)
511 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

It could be a number of things. can you attach the drawing document to investigate?

0 Likes
Message 3 of 4

MechMachineMan
Advisor
Advisor
Accepted solution
'-------------Start of ilogic ------------------------------------------------
'get the path and name of the drawing file
path_and_name = ThisDoc.PathAndFileName(False) ' without extension


'define oDoc
oDoc = ThisDoc.Document


'specify the drawing sheet
Try oSheet = oDoc.Sheets("Blatt:1") ' sheet by name 'oSheet = oDoc.Sheets(1) ' first sheet
Catch
MsgBox("Error Accessing Sheet!")
End Try Try ' say there is a Partslist on the sheet. oPartslist = oSheet.PartsLists(1)
Catch
MsgBox("Error Accessing PartsList!")
End Try ' create a new NameValueMap object oOptions = ThisApplication.TransientObjects.CreateNameValueMap 'specify an existing template file 'to use For formatting colors, fonts, etc oOptions.Value("Template") = "c:\temp\_Vorlage.xls" 'specify the columns to export oOptions.Value("ExportedColumns") = "POS;ANZ;MENGE;EINH;BENENNUNG;ARTIKEL NR.;ABMESSUNG/DIN" 'specify the start cell oOptions.Value("StartingCell") = "A10" 'specify the XLS tab name 'here the file name is used oOptions.Value("TableName") = ThisDoc.FileName(False) 'without extension 'choose to include the parts list title row 'in this example "Ye Old List of Parts" is written to the StartingCell oOptions.Value("IncludeTitle") = False 'choose to autofit the column width in the xls file oOptions.Value("AutoFitColumnWidth") = True
Try ' export the Partslist to Excel with options oPartslist.Export(path_and_name & ".xls", _ PartsListFileFormatEnum.kMicrosoftExcel, oOptions)
Catch
MsgBox("Error with parameters in PartsList.Export method!")
End try '-------------End of ilogic ------------------------------------------------

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
Message 4 of 4

martinhoos
Advocate
Advocate

Hi Hustin, thank you very much... ! Thats it.

Regards Martin

0 Likes