Esempio n. 1
0
        public void RunWithArguments(Document doc, NameValueMap map)
        {
            if (doc == null && map.HasKey("ilod"))
            {
                string docPath = map.AsString("ilod");
                LogTrace($"Opening /ilod document name: {docPath}");

                if (docPath.ToUpper().EndsWith(".IAM"))
                {
                    FileManager fm = _inventorApplication.FileManager;

                    string dvActRep = fm.GetLastActiveDesignViewRepresentation(docPath);
                    LogTrace($"LastActiveDesignViewRepresentation: {dvActRep}");

                    string lodActRep = fm.GetLastActiveLevelOfDetailRepresentation(docPath);
                    LogTrace($"LastActiveLevelOfDetailRepresentation: {lodActRep}");

                    NameValueMap openOptions = _inventorApplication.TransientObjects.CreateNameValueMap();
                    openOptions.Add("LevelOfDetailRepresentation", lodActRep);
                    openOptions.Add("DesignViewRepresentation", dvActRep);

                    doc = _inventorApplication.Documents.OpenWithOptions(docPath, openOptions, false);
                }
                else
                {
                    doc = _inventorApplication.Documents.Open(docPath, false);
                }
                LogTrace($"Full document name: {doc.FullDocumentName}");
            }

            ExecWithArguments(doc, map);
        }
Esempio n. 2
0
        public void RunWithArguments(Document doc, NameValueMap map)
        {
            LogTrace("Processing " + doc.FullFileName);

            try
            {
                // Using NameValueMapExtension
                if (map.HasKey("intIndex"))
                {
                    int intValue = map.AsInt("intIndex");
                    LogTrace($"Value of intIndex is: {intValue}");
                }

                if (map.HasKey("stringCollectionIndex"))
                {
                    IEnumerable <string> strCollection = map.AsStringCollection("stringCollectionIndex");

                    foreach (string strValue in strCollection)
                    {
                        LogTrace($"String value is: {strValue}");
                    }
                }

                if (doc.DocumentType == DocumentTypeEnum.kPartDocumentObject)
                {
                    using (new HeartBeat())
                    {
                        // TODO: handle the Inventor part here
                    }
                }
                else if (doc.DocumentType == DocumentTypeEnum.kAssemblyDocumentObject) // Assembly.
                {
                    using (new HeartBeat())
                    {
                        // TODO: handle the Inventor assembly here
                    }
                }
            }
            catch (Exception e)
            {
                LogError("Processing failed. " + e.ToString());
            }
        }