public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Document doc = commandData.Application.ActiveUIDocument.Document; StlImportProperties.GetProperties().SetGraphicsStyleToSketch(doc); return(Result.Succeeded); }
public static StlImportProperties GetProperties() { if (s_properties == null) { s_properties = new StlImportProperties(); } return(s_properties); }
private void ImportSTLDocument( STLDocument stlDocument, Document doc, string stlDocumentName) { StlImportProperties properties = StlImportProperties.GetProperties(); using (Transaction t = new Transaction(doc, "Import STL")) { t.Start(); TessellatedShapeBuilder builder = new TessellatedShapeBuilder(); builder.OpenConnectedFaceSet(false); int i = 0; foreach (Facet facet in stlDocument.Facets) { builder.AddFace(FromFacet(facet)); i++; } builder.CloseConnectedFaceSet(); TessellatedShapeBuilderResult result = builder.Build(properties.Target, properties.Fallback, properties.GraphicsStyleId); // Pre-release code from DevDays //DirectShape ds = DirectShape.CreateElement( // doc, result.GetGeometricalObjects(), "A", "B"); //ds.SetCategoryId(new ElementId( // BuiltInCategory.OST_GenericModel)); // Code updated for Revit UR1 ElementId categoryId = new ElementId(BuiltInCategory.OST_GenericModel); DirectShape ds = DirectShape.CreateElement(doc, categoryId, "A", "B"); ds.SetShape(result.GetGeometricalObjects()); ds.Name = stlDocumentName; t.Commit(); } }
public void ImportSTL(Document doc) { String assemblyPath = this.GetType().Assembly.Location; String stlPath = Path.Combine(assemblyPath, "STL files"); String filename = SelectSTLFile(stlPath); if (filename == null) { return; } String documentName = Path.GetFileName(filename); // Read from file if (StlImportProperties.GetProperties().Binary) { using (BinaryReader reader = new BinaryReader(File.Open(filename, FileMode.Open))) { STLDocument document = STLDocument.Read(reader); ImportSTLDocument(document, doc, documentName); reader.Close(); } } else { using (StreamReader reader = new StreamReader(filename)) { STLDocument document = STLDocument.Read(reader); ImportSTLDocument(document, doc, documentName); reader.Close(); } } }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { StlImportProperties.GetProperties().SetModeToBinary(); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { StlImportProperties.GetProperties().SetGraphicsStyleToInvalid(); return(Result.Succeeded); }