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: b.slootenMHLJY

Hi @b.slootenMHLJY.  You may need to change from using ThisApplication.ActiveDocument to using ThisDoc.Document to set the value of your initial oDrawDoc variable, because it is possible, in some situations for it to be pointing to the wrong document (one you are not expecting).  It will not be a problem when you have that drawing visibly open, and the 'active' document when you manually run the rule, but it can be a problem if triggered to run in other ways, or while other documents are open, where that drawing may not actually be the 'active' document.  It may also help avoid potential errors by integrating a DocumentType check in those first few lines, to make sure you are working with a DrawingDocument, instead of just assuming it will be one.  If it is not a DrawingDocument, then trying to access the ActiveSheet will fail.

 

Here is an example bit of code you could use instead:

If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
	MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
	Exit Sub
End If
Dim oDrawDoc As DrawingDocument = ThisDoc.Document

Wesley Crihfield

EESignature

(Not an Autodesk Employee)