Drawing automation - insert base view error

Drawing automation - insert base view error

dmackenzie2QH4Q
Explorer Explorer
596 Views
2 Replies
Message 1 of 3

Drawing automation - insert base view error

dmackenzie2QH4Q
Explorer
Explorer

Hi.  I am working in Inventor 2021.  I have an assembly file that I want to add a rule to launch a template drawing, insert 2 different base views, add some leaders, dimensions and a table based on the assembly file parameters.

The rule works well to open the template file but when inserting the first base view I am getting the following error:

 

"Error in rule: Create drawing, in document: 1-Bar program for 300T umbilical reel lift beam2.iam

Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"

 

I've googled that error and it seems to happen in different software's and for different reasons.  Any help is much appreciated as I still have a long way ahead to get the final product completed.

 

The code is as follows:

 

'create drawing

Dim oDrawingDoc As DrawingDocument    
Dim DWGTemplate As String = "C:\Autodesk\Workspace\Inventor\Projetos\Teste\1-bar program test\300T SB for reel lifts\Benton Solutions.idw"

oDrawingDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, DWGTemplate, True)

fpath = ThisDoc.Path
fname = ThisDoc.FileName
oAssyDocPath = fpath + "\" + fname + ".iam"
oAssyDoc = ThisApplication.Documents.Open(oAssyDocPath, False)


oSheet = oDrawingDoc.Sheets.Item(1)
oTG = ThisApplication.TransientGeometry
oPoint1 = oTG.CreatePoint2d(5, 5)
oBaseView = oSheet.DrawingViews.AddBaseView(oDrawingDoc, oPoint1, 1, ViewOrientationTypeEnum.kIsoTopLeftViewOrientation, DrawingViewStyleEnum.kHiddenLineRemovedDrawingViewStyle, "Default")

 

 

 

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

WCrihfield
Mentor
Mentor
Accepted solution

In your DrawingViews.AddBaseView() line, your specifying the wrong document variable for the 'model' document.  You're specifying the drawing document itself, instead of the assembly document.  Try specifying the oAssyDoc variable in there instead of your oDrawingDoc variable.

 

If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.

If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 3

dmackenzie2QH4Q
Explorer
Explorer

Worked like a charm.  Much simpler than expected.  Appreciate the help!

0 Likes