Custom SheetFormat "Doesn't Exist" Within My Code

Custom SheetFormat "Doesn't Exist" Within My Code

MechMachineMan
Advisor Advisor
298 Views
1 Reply
Message 1 of 2

Custom SheetFormat "Doesn't Exist" Within My Code

MechMachineMan
Advisor
Advisor

So As the title says, in one drawing I made a custom sheet format (by right clicking a sheet name) then saved this as a document template.

 

I'm making a code to automate drawing creations, and in this I must change sheet formats so that the sheets don't look like crap.

 

Anyways, in doing so, my code with recognize and function properly if I use anyone of the default sheet formats, but fails if I use mine.

 

There last 2 lines of the error that it keeps throwing is:

 

System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

 

Now, I have read somewhere that this error appears when the file cannot be found in memory, or is having memory issues. This leads to believe that the code doesn't think it exists. However, when I go create a file with my template file, it clearly does.

 

Any help would be appreciated! Thanks!

 

SyntaxEditor Code Snippet

Private Sub CreateDwgDoc(oModelName As String, oDrawingDoc As DrawingDocument)

Dim oModel As Document
Dim oDocs As Documents = ThisApplication.Documents
Dim oFormat As SheetFormat


     oModel= oDocs.ItemByName(oModelName)   
    
     oFormat = oDrawingDoc.SheetFormats.Item(7)
    
     oDrawingDoc.Activate

     oDrawingDoc.Sheets.AddUsingSheetFormat(oFormat, oModel, "Shee",,,)

--------------------------------------
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
0 Likes
299 Views
1 Reply
Reply (1)
Message 2 of 2

MechMachineMan
Advisor
Advisor
Well. I figured it out.

My SheetFormat I was copying and trying to use didn't have model views placed in it, whereas mine did. And my code was for a sheet format that had a model in (as indicated by the oModel argument present.)

The fix was simply to remove oModel.
Alternatively, I could have just used a view in my sheet format.

--------------------------------------
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
0 Likes