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

Hi @e_jeanUH6EY.  Your attached code is very difficult for me to read through and follow along with, and looks like it may have been VBA at some point, then converted to vb.net later.  I can see that down where you are exporting to a DWG file, you appear to be getting the DataIO object from a variable named 'docdefinition', which I believe represents some sort of ComponentDefinition.  Since this is likely a definition of some reference document, instead of the definition of the main assembly, I am not sure if simply activating the first ModelState found within that definition will be enough to make that export line of code work the way you want.  If you had the part open directly, and visibly on your screen, then activating the first ModelState before doing anything else would work, but that is not the case in your code, which is being ran from your main assembly.  This is because of how you obtained the value of that variable (docdefinition) in the first place.  You would need to first make sure you have a reference to the Document object associated with the first ModelState in that file, then get the ComponentDefinition from that Document, as the value of that variable.  That way that variable represents the ComponentDefinition of the Primary/Master Document version of that file, which is what you want to export from. 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)