Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
WCrihfield
in reply to: raymaster

OK.  Those first two steps listed can definitely be tricky.

There is a Sheet.CopyTo() method, which sounds like it should be the right one to use, but it can only be used to copy the sheet to another drawing document, not for copying the sheet within the same drawing document.  It says so right in its online documentation.  That is why I assumed that the only other two options for copying the sheet are to create a SheetFormat based on the existing sheet (even if just a temporary one, that we can delete again later), then use that SheetFormat we just created to create a new sheet exactly the same as the existing one.  Otherwise we would have to create the next sheet the longer way.  The thought does come to mind to use a second, temporary drawing document, copy the sheet to it, then copy it back to the original drawing, but I do not recall if I have tried that idea before, and it may require a bit more system resources/processing/memory.  

 

The DrawingView object has a property named ActiveModelState, which may seem like the way to go, but the problem is that it is a ReadOnly property.  So we can check it, but cant change its value directly.  However, the DrawingView object also has a method (DrawingView.SetActiveModelState) just for setting its value, which also has a couple other optional setting you can specify, such as if you want to update any PartsList that may be based on that view, and if you want to keep any overrides.  I do not know exactly why it is set-up that way, only that this is the way it must be done.  Also, I think this method may only work on 'Base Views', and may not work on other types of view like projected, because they are controlled by the view they are projected from.  It also says that this method will fail if the reference to the model is 'unresolved'.  It does seem like I may have heard of some awkward behavior in this area though, but I can not remember the details, since I do not do a lot of in-depth drawing side automation where I work.

 

If I get a chance later, I may attempt to create some code for this task, test it, and get back with you.  I've got to deal with some other stuff at the moment though.  Sometimes I spread myself too thin across multiple projects (multi-tasking).

Wesley Crihfield

EESignature

(Not an Autodesk Employee)