示例#1
0
        /// <summary>
        /// Tries to get an Inventor.Document object from a supplied object.  If one is found it will be returned; if not, null is returned.
        /// </summary>
        /// <param name="obj">Object</param>
        /// <returns>Inventor.Document</returns>
        public static Document GetDocumentFromObject(this Object obj)
        {
            if (ObjectIsDocument(obj))
            {
                return((Document)obj);
            }

            Inventor.Application app = ApplicationShim.CurrentInstance();
            if (app == null)
            {
                return(null);
            }

            Document currentDocument = app.ActiveEditDocument;

            switch (currentDocument.DocumentType)
            {
            case DocumentTypeEnum.kPartDocumentObject:
                return(currentDocument);

            case DocumentTypeEnum.kAssemblyDocumentObject:
                return(GetDocumentFromObjectInAssembly(obj));

            case DocumentTypeEnum.kDrawingDocumentObject:
                return(GetDocumentFromObjectInDrawing(obj, (DrawingDocument)currentDocument));

            case DocumentTypeEnum.kDesignElementDocumentObject:     //12294
            case DocumentTypeEnum.kForeignModelDocumentObject:      //12295
            case DocumentTypeEnum.kNoDocument:                      //12297
            case DocumentTypeEnum.kPresentationDocumentObject:      //12293
            case DocumentTypeEnum.kSATFileDocumentObject:           //12296
            case DocumentTypeEnum.kUnknownDocumentObject:           //12289
            default:
                return(null);
            }
        }
 /// <summary>
 /// Constructor that creates an ExternalRuleDirectories object.
 /// </summary>
 public ExternalRuleDirectories()
 {
     _app = ApplicationShim.Instance();
     Initialize(_app);
 }