Announcements
Welcome to the Revit Ideas Board! Before posting, please read the helpful tips here. Thank you for your Ideas!
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autodesk Answer Day: Edit sketch in API

Autodesk Answer Day: Edit sketch in API

I would like to have the edit sketch in an API.  We would like to edit the sketch of floors, walls and filled regions.

 

 

Just a suggestion.  

Thank you. 

22 Comments
bosborne
Advocate

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...

JanUsinger
Enthusiast

I can help you with my thumb, bosborne.

 

bosborne
Advocate
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).

Reference: http://forums.autodesk.com/t5/revit-api/edit-existing-slab-boundary/td-p/4407975
boostyourbim
Advocate

For floors, roofs, ceilings, etc. the API should support editing the sketch of an existing element.

 

This workaround is not sufficient because it does not allow changing the # of elements in the sketch

http://adndevblog.typepad.com/aec/2013/10/change-the-boundary-of-floorsslabs.html

 

For more info, see http://forums.autodesk.com/t5/revit-ideas/autodesk-answer-day-edit-sketch-in-api/idi-p/6334613

boostyourbim
Advocate
bosborne
Advocate

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???).  

e_juma
Enthusiast

I also want it. Let us push it to the top.

HZWWKJ
Participant

I need it. Let us push it to the top.

raphael.geffroy
Participant

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.

bixilix
Contributor

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.. 🙂

f.deagostini
Explorer

It have no sense that Revit API cannot edit those fundamental objects. Vote this up: walls, floors and roof are the basics of a bim software.

This seems to be stuck in voting oblivion. But have a vote regardless

f.deagostini
Explorer

God listened us: https://blogs.autodesk.com/revit/2020/04/20/revit-public-roadmap-update-april-2020/

For everyone section, API sketches ❤️ 

kimberly.fuhrman
Autodesk
Status changed to: Accepted

Congrats! We think this is a great idea, so we've decided to add it to our roadmap. Thanks for the suggestion!

 

The Factory

OlegSheydvasser
Autodesk

You may want to look at the Revit Preview (aka beta) if you are interested in new sketch-based element creation and editing via API:

Ceiling creation API 

Sloped Ceiling creation API

Floor creation API

 

Get Sketch elements API

Sketch Edit Mode API

Floor Sketch editing API

Wall and Shaft Opening Sketch editing API

 

To join the Revit Preview email revit.preview.access@autodesk.com 

 

jaxonfortune
Explorer

@OlegSheydvasser It's great this is on the ToDo list, but do we have any idea when this will be released.

2022 ?? (fingers crossed)

f.deagostini
Explorer

It is on the "DONE" list, actually in testing phase. You can join the beta program if you like to.

Hopefully it will be released on next version, usually on mid-late april.

kimberly.fuhrman
Autodesk
Status changed to: Implemented

We are pleased to say that this has been implemented in Revit 2022!

 

-The Factory

jaxonfortune
Explorer

@kim Are there any instructional videos or sample code that can be shared on the new Sketch API Implementation?

OlegSheydvasser
Autodesk

Here's the sample:

/*
 * 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;
        }
    }
}

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea  

Autodesk Design & Make Report


Autodesk Design & Make Report