- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have made an ilogic rule to quickly copy sheets in a drawing rather than manually using the workaround of copying and pasting into a separate drawing file and then copying it back. The ilogic uses the same workaround, simply copying the currently active sheet to an empty drawing file I created for this purpose. However the first time I run this rule after opening inventor I get an error saying "Unable to cast object of type 'Inventor._DocumentClass' to type 'Inventor._DrawingDocument'." Every time I run the rule after that it works perfectly with no errors. I'm curious if anyone knows why this may be happening, as it's been annoying to troubleshoot considering I need to restart inventor every time I want to test a possibly fix. I am using the most recent version of inventor 2019.
Dim oDrawDoc As DrawingDocument oDrawDoc = ThisDoc.Document Dim oActiveSheet As Sheet oActiveSheet = oDrawDoc.ActiveSheet CopyNumString = InputBox("Number of copies of current sheet?", "Copy current sheet", 1) Try CopyNum=CDbl(CopyNumString) Catch MessageBox.Show("Must imput a number") Return End Try Dim CopyDest As DrawingDocument CopyDest=ThisApplication.Documents.Open("FILE PATH TO BLANK DRAWING DOCUMENT", False) Dim oCopySheet As Sheet oCopySheet = oActiveSheet.CopyTo(CopyDest) While CopyNum>0 oCopySheet.CopyTo(oDrawDoc) CopyNum = CopyNum - 1 End While oCopySheet.Delete
Solved! Go to Solution.