Error When Trying To Place Drawing View

Error When Trying To Place Drawing View

Anonymous
Not applicable
1,124 Views
6 Replies
Message 1 of 7

Error When Trying To Place Drawing View

Anonymous
Not applicable

I've been trying to figure out how to place a base drawing view in an Inventor Drawing and used the code given in the API help section in Inventor, but when I try and run the code I get this error:

 

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

And this on the more info tab

 

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)
at Inventor.DrawingViews.AddBaseView(_Document Model, Point2d Position, Double Scale, ViewOrientationTypeEnum ViewOrientation, DrawingViewStyleEnum ViewStyle, String ModelViewName, Object ArbitraryCamera, Object AdditionalOptions)
at LmiRuleScript.Main()
at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

 

Is there a way to find out which parameter is incorrect or has there been a change in how views are placed and the help section hasn't been updated?

0 Likes
Accepted solutions (1)
1,125 Views
6 Replies
Replies (6)
Message 2 of 7

bradeneuropeArthur
Mentor
Mentor
Use messageboxes to trace where the failure is.
Otherwise upload the code an I can check.

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 7

Anonymous
Not applicable

This is what I'm using.

0 Likes
Message 4 of 7

HermJan.Otterman
Advisor
Advisor
Accepted solution

Hello D.

 

I changed the for last line...

 

        Dim oDrawingDoc As DrawingDocument
        oDrawingDoc = ThisApplication.ActiveDocument

        Dim oSheet As Sheet
        oSheet = oDrawingDoc.Sheets.Item(1)

        Dim oPoint1 As Point2d
        oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(5.0#, 5.0#)

        Dim oPartDoc As PartDocument
        oPartDoc = ThisApplication.Documents.Open("C:\temp\test\test.ipt") ' ("C:\Users\Daniel\Desktop\Copy Test\Wall Bench\Top.ipt", False)

        Dim oView1 As DrawingView
        oView1 = oSheet.DrawingViews.AddBaseView(oPartDoc,
            oPoint1, 1.0#, ViewOrientationTypeEnum.kBottomViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)


        Call oPartDoc.Close(True)

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes
Message 5 of 7

Anonymous
Not applicable

If I were to try and use the same process for an assembly what steps would I need to change, as I have just tried and it has come up with this error

 

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartDocument'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{29F0D463-C114-11D2-B77F-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).
0 Likes
Message 6 of 7

bradeneuropeArthur
Mentor
Mentor
im oPartDoc As assemblyDocument
        oPartDoc = 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 7 of 7

MechMachineMan
Advisor
Advisor

Well, if you read the error, you can see it has a keyword in there or 2.

 

Correspondingly, if you read your code you'll notice on one line it says "Dim ___ As PartDocument"

 

Now, seeing as you asked about doing an assembly document instead, it doesn't make too much sense we would be telling the code we want to use a part document.

 

If you look up the "Document" class of objects available, you'll see there are multiple

 

1. The Generic Document type

2. The DrawingDocument type

3. The AssemblyDocument type

4. The PresentationDocument type

5. The PartDocument type.

 

The generic type works in almost all cases and is the easiest to use. The specific types are less prone to errors, but requires lots of swapping.


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