Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Show only
|
Search instead for
Did you mean:
This page has been translated for your convenience with an automatic translation service. This is not an official translation and may contain errors and inaccurate translations. Autodesk does not warrant, either expressly or implied, the accuracy, reliability or completeness of the information translated by the machine translation service and will not be liable for damages or losses caused by the trust placed in the translation service.Translate
I'm tempted to create 100 user accounts just to vote this to the top. Great suggestion. Would do wonders for those of us that work in the API/Dynamo world...
Thanks Jan. Really - I'm not sure if it is the sketch mode that is really needed to make this happen, but really just the ability to edit the reference array of the floor/roof/shaft etc from within the API. There are some ways that have been suggested to do this, but they are not really viable solutions for life in the real world (as in what happens when a 4 sided box gets a re-entrant corner and now has 6 sides).
I wish i could give this 200 votes and push it to the top (I'd say this is even more important than having "Or" in filters). Non-API users - Please vote for this. Having this capability will allow for so many improved workflows (can you say Dynamo replacing Copy/Monitor???).
I add my vote. For several days, I'm looking for a method to modify the sketch of a slab. In structure, we often cut a floor in 2 to add a beam between the two, for example.
This would make so much sense... It spent so much time to find a solution for this, but I did not expect it to be "just not possible". It does not seem to be too complicated to implement this and I found threads from 2008 wishing for this feature... Please do it, even if it´s 12 years late.. 🙂
/*
* Created by SharpDevelop.
* User: t_matva
* Date: 11/17/2020
* Time: 11:18 AM
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;
namespace Sample
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("994A64E6-839B-4C1F-B473-1E7C614A5455")]
public partial class ThisDocument
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
public void CreateFloor()
{
Curve left = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 100, 0));
Curve upper = Line.CreateBound(new XYZ(0, 100, 0), new XYZ(100, 100, 0));
Curve right = Line.CreateBound(new XYZ(100, 100, 0), new XYZ(100, 0, 0));
Curve lower = Line.CreateBound(new XYZ(100, 0, 0), new XYZ(0, 0, 0));
CurveLoop floorProfile = new CurveLoop();
floorProfile.Append(left);
floorProfile.Append(upper);
floorProfile.Append(right);
floorProfile.Append(lower);
ElementId levelId = Level.GetNearestLevelId(Document, 0.0);
using (Transaction transaction = new Transaction(Document))
{
transaction.Start("Create floor");
ElementId floorTypeId = Floor.GetDefaultFloorType(Document, false);
Floor floor = Floor.Create(Document, new List<CurveLoop>() { floorProfile }, floorTypeId, levelId);
transaction.Commit();
}
}
// Find a line in a sketch, delete it and create an arc in its place.
public void ReplaceBoundaryLine()
{
FilteredElementCollector floorCollector = new FilteredElementCollector(Document)
.WhereElementIsNotElementType()
.OfCategory(BuiltInCategory.OST_Floors).OfClass(typeof(Floor));
Floor floor = floorCollector.FirstOrDefault() as Floor;
if (floor == null)
{
TaskDialog.Show("Error", "Document does not contain a floor.");
return;
}
Sketch sketch = Document.GetElement(floor.SketchId) as Sketch;
Line line = null;
foreach (CurveArray curveArray in sketch.Profile)
{
foreach (Curve curve in curveArray)
{
line = curve as Line;
if (line != null)
{
break;
}
}
if (line != null)
{
break;
}
}
if (line == null)
{
TaskDialog.Show("Error", "Sketch does not contain a straight line.");
return;
}
// Start a sketch edit scope
SketchEditScope sketchEditScope = new SketchEditScope(Document, "Replace line with an arc");
sketchEditScope.Start(sketch.Id);
using (Transaction transaction = new Transaction(Document, "Modify sketch"))
{
transaction.Start();
// Create arc
XYZ normal = line.Direction.CrossProduct(XYZ.BasisZ).Normalize().Negate();
XYZ middle = line.GetEndPoint(0).Add(line.Direction.Multiply(line.Length / 2));
Curve arc = Arc.Create(line.GetEndPoint(0), line.GetEndPoint(1), middle.Add(normal.Multiply(20)));
// Remove element referenced by the found line.
Document.Delete(line.Reference.ElementId);
// Model curve creation automatically puts the curve into the sketch, if sketch edit scope is running.
Document.Create.NewModelCurve(arc, sketch.SketchPlane);
transaction.Commit();
}
sketchEditScope.Commit(new FailuresPreprocessor());
}
// Adds new profile to the sketch.
public void MakeHole()
{
FilteredElementCollector floorCollector = new FilteredElementCollector(Document)
.WhereElementIsNotElementType()
.OfCategory(BuiltInCategory.OST_Floors).OfClass(typeof(Floor));
Floor floor = floorCollector.FirstOrDefault() as Floor;
if (floor == null)
{
TaskDialog.Show("Error", "Document does not contain a floor.");
return;
}
Sketch sketch = Document.GetElement(floor.SketchId) as Sketch;
// Create a circle inside the floor
// Start a sketch edit scope
SketchEditScope sketchEditScope = new SketchEditScope(Document, "Add profile to the sketch");
sketchEditScope.Start(sketch.Id);
using (Transaction transaction = new Transaction(Document, "Make a hole"))
{
transaction.Start();
// Create and add an ellipse
Curve circle = Ellipse.CreateCurve(new XYZ(50, 50, 0), 10, 10, XYZ.BasisX, XYZ.BasisY, 0, 2 * Math.PI);
// Model curve creation automatically puts the curve into the sketch, if sketch edit scope is running.
Document.Create.NewModelCurve(circle, sketch.SketchPlane);
transaction.Commit();
}
sketchEditScope.Commit(new FailuresPreprocessor());
}
}
public class FailuresPreprocessor : IFailuresPreprocessor
{
public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
{
return FailureProcessingResult.Continue;
}
}
}