Exemplo n.º 1
0
        public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elements)
        {
            form frmCmd = new form(cmdData, msg, elements);

            frmCmd.Show();
            return(Result.Succeeded);
        }
Exemplo n.º 2
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;

            form     fm  = new form();
            Document doc = app.OpenDocumentFile(TextPath);

            //决定导出的元素
            FilteredElementCollector collector = null;

            collector = new FilteredElementCollector(doc);

            collector.WhereElementIsNotElementType().WhereElementIsViewIndependent();

            ObjExporter exporter = new ObjExporter();
            Options     opt      = app.Create.NewGeometryOptions();

            ExportElements(exporter, collector, opt);



            Directory.CreateDirectory(@"D:\to_obj\" + TextName.ToString());
            exporter.ExportTo(@"D:\to_obj\" + TextName.ToString() + @"\" + TextName.ToString() + ".obj".ToString());

            Directory.CreateDirectory(@"D:\to_obj\" + TextName.ToString() + @"\" + "Texture");
            //var objlibraryAsset = app.get_Assets(AssetType.Appearance);
            //foreach (Element elem in collector)
            //{
            //    string theValue = null;
            //    ICollection<ElementId> ids = elem.GetMaterialIds(false);
            //    foreach (ElementId id in ids)
            //    {
            //        Material mat = doc.GetElement(id) as Material;
            //        AssetPropertyString bitmapProperty = null;
            //        AssetProperty property;

            //        ElementId appearanceId = mat.AppearanceAssetId;
            //        AppearanceAssetElement appearanceElem = doc.GetElement(appearanceId) as AppearanceAssetElement;
            //        Asset asset = appearanceElem.GetRenderingAsset();
            //        if (0 != asset.Size)
            //        {
            //            for (var j = 0; j < asset.Size; j++)
            //            {
            //                property = asset[j];
            //                if (property.Name == BitmapPropertyName)
            //                {
            //                    bitmapProperty = property as AssetPropertyString;
            //                    if (bitmapProperty != null)
            //                    {
            //                        theValue = bitmapProperty.Value;
            //                        break;
            //                    }
            //                }
            //            }
            //        }
            //        else
            //        {
            //            foreach (Asset objCurrentAsset in objlibraryAsset)
            //            {
            //                if (objCurrentAsset.Name == asset.Name &&
            //                    objCurrentAsset.LibraryName == asset.LibraryName)
            //                {
            //                    theValue = objCurrentAsset.Type.ToString();
            //                }
            //            }
            //        }

            //    }
            //    if (theValue != null)
            //    {
            //        TaskDialog.Show("lalala", theValue);
            //    }


            //}
            return(Result.Succeeded);
        }