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 a surface through Revit API

17 REPLIES 17
SOLVED
Reply
Message 1 of 18
carolinalm
6683 Views, 17 Replies

Create a surface through Revit API

Hi!


I need to create a surface in Revit API with some points. The surface can be anything, like a roof, a floor, or another component. The surface is not plane. Is there any command that can do this? Or I need to find a way to divide the surface in little plans?


Thanks.

17 REPLIES 17
Message 2 of 18
Charles.Piro
in reply to: carolinalm

Hi,

 

Here is a solution for create a floor from points :

 

 

 UIApplication uiapp = extCmdData.Application;
            UIDocument uiDoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uiDoc.Document;
            Transaction trans = new Transaction(doc);
            try
            {              
                trans.Start();
                XYZ[] points = new XYZ[5];
                points[0] = new XYZ(0.0, 0.0, 0.0);
                points[1] = new XYZ(10.0, 0.0, 0.0);
                points[2] = new XYZ(10.0, 10.0, 0.0);
                points[3] = new XYZ(0.0, 10.0, 0.0);
                points[4] = new XYZ(0.0, 0.0, 0.0);

                CurveArray curve = new CurveArray();

                for (int i = 0; i < 4; i++)
                {
                    Line line = Line.CreateBound(points[i],
                      points[i + 1]);

                    curve.Append(line);
                }
                
                doc.Create.NewFloor(curve, true);
                
            }
            catch (Exception e)
            {
                trans.RollBack();
                msg = e.Message;
                return Result.Failed;
            }
            trans.Commit();
            return Result.Succeeded;

 

You can find the same method for create FilledRegion here :http://thebuildingcoder.typepad.com/blog/2013/07/create-a-filled-region-to-use-as-a-mask.html

 

 



PIRO Charles
Developer

PIRO CIE
Linkedin


Message 3 of 18
jeremytammik
in reply to: carolinalm

Dear Carolinalm,

 

You have a quite large number of options, really.

 

It sepends on what you really need, of course.

 

I would start by looking at the form creation API:

 

http://thebuildingcoder.typepad.com/blog/2009/07/revit-form-creation-api.html

 

That is pretty old, though.

 

The newest and maybe easiest option might be the DirectShape element:

 

http://thebuildingcoder.typepad.com/blog/2015/07/intersect-solid-filter-avf-and-directshape-for-debu...

 

http://thebuildingcoder.typepad.com/blog/2015/02/from-hack-to-app-obj-mesh-import-to-directshape.htm...

 

So maybe I would actually start by looking at that.

 

There are lots of other possibilities as well, as pointed out by Goldorak44.

 

Good luck making a good choice!

 

Please let us know how it works out.

 

Thank you!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 18
jeremytammik
in reply to: Charles.Piro

Dear Goldorak44,

 

Please note that it is better to encapsulate the transaction in a using statement:

 

http://thebuildingcoder.typepad.com/blog/2015/07/clicks-dmu-surfaces-firerating-feedback-vacation.ht...

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 18
Charles.Piro
in reply to: carolinalm

Ok, thanks for the tips.



PIRO Charles
Developer

PIRO CIE
Linkedin


Message 6 of 18
carolinalm
in reply to: carolinalm

Goldorak44, thank you for your answer, but I think Jeremy understood better my doubt.

Thank you Jeremy! I will try to solve my problem, and if it succeed I reply here.

Message 7 of 18
carolinalm
in reply to: jeremytammik

Jeremy,

I choose make the surface through Loft Creation, but I found out that the command "FamilyCreate" can only be used in Family Editor. Is there any way to open the Family Editor through a project document?

 

Thanks,

Carolina.

Message 8 of 18
Revitalizer
in reply to: carolinalm

Hi Carolinalm,

 

as far as I know, Jeremy is on vacation.

 

To your topic:

You can use DirectShape in project context from Revit 2016 on.

 

 

Best regards,

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 9 of 18
carolinalm
in reply to: Revitalizer

Hi Revitalizer,

 

For now I managed to create a surface by running the code from within a mass template. I'm creating a loft form.

 

But thank you for your help!

Message 10 of 18
218001566
in reply to: carolinalm

Hi Carolinalm,

 

I am interested in your problem/solution, as (among other things) I am trying to extrude a toposurface (or a polysurface). For the company I work for, we do a lot of entertainment and animal exhibitions, which incorporates fake natural environments with personnel/staff rooms underneath. For example, a penguin exhibition that emulates rocks, stones, etc, in the form of a sloped terrain, and we have maintenance rooms underneath that the general public do not see. So when we create our construction drawings, and more specifically sections, we always fake that sloped terrain thickness with filled regions in Revit.

 

In Dynamo, we can translate a toposurface into a polysurface, but I haven't been able to extrude that as of now. If you have any progress into something similar, please let me know how you did it.

 

Best regards,

Message 11 of 18
carolinalm
in reply to: 218001566

I thought about your question and I think you can create a mass (conceptual mass) with the points of the surface and then create a roof by face with the mass. I am working with mass in this moment, creating loft forms (http://thebuildingcoder.typepad.com/blog/2009/07/revit-form-creation-api.html). I just don't know yet if it's possible to create roof by face through Revit API.

 

Best regards,

Carolina.

Message 12 of 18
218001566
in reply to: carolinalm

Thanks Carolina, but I have just got the solution to it by using Dynamo. 

 

Good luck!

Message 13 of 18
dkinjal
in reply to: 218001566

Hello Carolina, Jeremy,

 

I am trying to figureout something very close to what you have been discussing here. Right now i am struggling with following items, it would be great if i can have answer/clues to any of these:

 

  • Using TessellatedShapeBuilder i get pretty good mass from my 3d coordinates. I am building it in Conceptual Mass family to later import to the intended project. Is it possible to skip a step and make it in-place without loosing capability of setting roofs & walls to its faces?
  • Is it possible via Revit API, to create Roofs & Walls from the faces of the mass (once it is loaded in the intended project)?

Thanks in advance.

 

Best regards,

Kinjal.

Message 14 of 18
jeremytammik
in reply to: dkinjal

Dear Kinjal,

 

Yes, yes. Yes to both.

 

1. A much more efficient approach than using a conceptual mass is going via the DirectShape element.

 

Have you not read my exciting blog posts on that topic?

 

I just created a new topic group for them:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.50

 

The direct shape element is created directly in the project.

 

No need for a family.

Possible performance improvement: factor of 1000.

 

2. http://thebuildingcoder.typepad.com/blog/2013/01/create-facewall-on-slanted-mass-face.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 15 of 18
dkinjal
in reply to: jeremytammik

Hey Jeremy,

 

Thanks for replying.

 

Indeed i have read many of your blogs and it has contributed a lot towards my understanding of how Revit api works (i am pretty new to Revit, couple of months). Very valuable, thank you for the good work.

 

@1: Sorry, i wasn't probably explicit enough in my question.

 

I did create the Solid using DirectShape in the project itself. However, the Solid created (programmatically) in the project did not exhibit the ability to accept Roof/Walls on its faces when tried in Revit UI (manually).

 

 

To get the better sense of what is going on, i sent it to Revit professional at my client and he said its a 'dumb' object, and suggested creating it in a Conceptual Mass family. I did so. Once the Solid (created programmatically in Family) is imported to the project, it responds to Roof/Wall by face commands in Revit UI.

 

 

Have you observed this difference in behaviour? Let me know if it isn't clear from my description. i can make a screen recording and post a link.

 

@2: Thanks for link to your blog on FaceWall. It is going to be help.


In your reply did you meant 'Yes' for Roofs as well?

 

For my current project the Roofs are trickest part to get right, so i was exploring APIs for possible ways to place Roof by Face. I have exhausted all possible areas to check without any success. Can you please shed some light on 'placing Roof by face' via API? It would be of tremendous help.

 

Additional: i found that when roofs are placed by face in Revit UI, the object that represent the roof instances are of type 'RoofBase' class. As far as i could explore, there are no public constructor, static factories nor any helper methods that would let me create an object of 'RoofBase'. Not sure where am i missing to look.

 

Thanks and thanks in advance.

 

Regards,
Kinjal.

Message 16 of 18
jeremytammik
in reply to: dkinjal

Dear Kinjal,

 

Revit 2016 added a bunch of features to DirectShape:

 

http://thebuildingcoder.typepad.com/blog/2015/04/whats-new-in-the-revit-2016-api.html#4.16

 

Referencing option

 

DirectShape elements now support by default element references, including dimensions, alignments, and face hosting, as well as snapping.

The property:

 

  • DirectShapeOptions.ReferencingOption

 

supports options related to the referenceablility of the DirectShape or DirectShapeType – if set to NotReferenceable, the geometry may not be used for dimensioning, snapping, alignment, or face-hosting. The element may still be selected by the user for operations which do not reference individual geometry objects.

 

I have no idea about roofs.

 

Can you please shed some light on 'placing Roof by face' manually via the user interface?

 

Whatever can be done manually should also be achievable through the API.

 

Chers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 17 of 18
dkinjal
in reply to: jeremytammik

Dear Jeremy,

 

Referenceing: Wasn't aware about ReferencingOptions, thanks. However, I found the defaults are set to Referenceable.

Just to be sure, i replaced  my code with the one from your sample (http://thebuildingcoder.typepad.com/blog/2014/05/directshape-performance-and-minimum-size.html). Still Revit UI doesn't allow picking those faces for placing Roof/Walls.

I will keep on trying and will post if/when i find the solution. In the meantime, if something in particular occurs to your mind please let me know. 

 

Roof by face: Oh i see. Can you please point me to a good resource for Roofs?

 

It is very encouraging to see your saying "Whatever can be done manually should also be achievable through the API".

However i am completely stuck on two aspects related to Roof:

  • Setting SlopedArrow to a FootPrintRoof (programmatically)
  • Creating Roof by Face (similar to FaceWall). I think Carolina also tried to figure it out sometime back.

Any reference to resources, hint, or signals will be highly useful and appreciated.

 

Thanks & Regards,

Kinjal

 

 

Message 18 of 18
jeremytammik
in reply to: dkinjal

Dear Kinjal,

 

As stated above, I do not know about the roof on face.

 

I have however recently and fully addressed your first point above on setting the slope of a FootPringRoof:

 

http://thebuildingcoder.typepad.com/blog/2015/09/revit-answer-day-and-creating-a-roof.html#4

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community