Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

create detail line from selected face edges

9 REPLIES 9
SOLVED
Reply
Message 1 of 10
desdinova
3033 Views, 9 Replies

create detail line from selected face edges

namespace RevitAddin61
{
    [Transaction(TransactionMode.Manual)]
    public class Command : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;

            Reference myRef = uidoc.Selection.PickObject(ObjectType.Face);
            Element e = doc.GetElement(myRef);
            GeometryObject geo = e.GetGeometryObjectFromReference(myRef);
            Face f = geo as Face;

           
            EdgeArrayArray loops = f.EdgeLoops;
            
            foreach (EdgeArray loop in loops)
            {
                foreach (Edge edge in loop)
                {

                    Curve curve = edge.AsCurve();
                    XYZ p = curve.GetEndPoint(0);
                    XYZ q = curve.GetEndPoint(1);
                    
                    Line line = Line.CreateBound(p, q);

                }
            }
           

            return Result.Succeeded;
        }
    }
}

Hello friends i want to create detail lines from selected face 

Line line = Line.CreateBound(p, q);

 Command doesn't work for me 

How can i do this.?

Thanks in advance....

9 REPLIES 9
Message 2 of 10
Anonymous
in reply to: desdinova

Curve.Clone
Message 3 of 10
Anonymous
in reply to: desdinova

Autodesk.Revit.Creation.ItemFactoryBase.NewDetailCurve

Message 4 of 10
Revitalizer
in reply to: desdinova

Hi desdinova,

 

for creating DetailCurves, you would need a proper view since they are view-depending.

You may use ModelCurves instead.

See TBC for creating ModelCurves examples, e.g.:

http://thebuildingcoder.typepad.com/blog/2015/04/curved-wall-elevation-profile-and-creator-class-upd...

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 5 of 10
desdinova
in reply to: Revitalizer

using (Transaction t = new Transaction(doc, "Detail Lines"))
                        {
                            t.Start();
                            Line line = Line.CreateBound(x1, x2);
                            DetailCurve detailCurve = doc.Create.NewDetailCurve(doc.ActiveView, line);

                            t.Commit();
                        }

Thank you.

The code above solved my problem.

But now i want to set linestyle for my detail curve.

Is it possible because the code draw thin lines i want to draw overhead lines

Message 6 of 10
Revitalizer
in reply to: desdinova

Hi desdinova,

 

yes, that's possible.

 

Just assign a GraphicsStyle object to the detailCurve.LineStyle property.

 

You will find a collection of proper ElementIds this way:

 

ICollection<ElementId> styleIDs = detailCurve.GetLineStyleIds();

 

Just get the relating Elements by those IDs, cast them to GraphicsStyle objects.

By comparing their names, you will get the one you want.

Note that each GraphicsStyle also has a GraphicsStyleType property, so there may be two of the same name of which you can use the one with GraphicsStyleType.Projection.

 

That's all.

 

 

Revitalizer

 




Rudolf Honke
Software Developer
Mensch und Maschine





Message 7 of 10
desdinova
in reply to: Revitalizer

 ICollection<ElementId> styleIDs = detailCurve.GetLineStyleIds();
                            foreach (ElementId id in styleIDs)
                            {
                                Element elem = doc.GetElement(id);
                                if(elem.Name=="<Overhead>")
                                {
                                    GraphicsStyle egs = elem as GraphicsStyle;
                                    detailCurve.LineStyle = egs;
                                }
                                

                            }

hi Revitalizer

Thank you for your reply.

now i want to draw detailCurve in under the floor plan 

How can i do that.?

 

Message 8 of 10
Revitalizer
in reply to: desdinova

Hi desdinova,

 

what do you mean saying "in under" the floor plan ?

Do you mean that you want to draw them in the ceiling plan belonging to the next lower level ?

So just use that view for drawing the DetailCurves.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 9 of 10
Anonymous
in reply to: Revitalizer

Hi Revitalizer,

 

Your tool works fine for me at "System Families", but when I am trying this on "Loadable families" like Duct Fittings it doesn't draw the lines. I can pick a face of an elbow but the tool will not draw the lines. When I pick a straight duct the lines will appear. Do you have any solution for my problem?

Message 10 of 10
Revitalizer
in reply to: Anonymous

Hi,

 

an elbow has a curved geometry, so no straight lines but curves.

The code creates new lines using the end points of an edge.

You could use the edge curves directly.

 

After creating ModelCurves, you could use Document.ConvertModelToDetailCurves() to display the projected curves in a given view.

 

https://forums.autodesk.com/t5/revit-api-forum/projection-transformation/m-p/9119247

 

 

Revitalizer

 

 




Rudolf Honke
Software Developer
Mensch und Maschine





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

Post to forums  

Autodesk Design & Make Report