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.
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
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
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:
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
Dear Goldorak44,
Please note that it is better to encapsulate the transaction in a using statement:
Cheers,
Jeremy
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.
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.
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
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!
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,
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.
Thanks Carolina, but I have just got the solution to it by using Dynamo.
Good luck!
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:
Thanks in advance.
Best regards,
Kinjal.
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
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.
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
DirectShape elements now support by default element references, including dimensions, alignments, and face hosting, as well as snapping.
The property:
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
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:
Any reference to resources, hint, or signals will be highly useful and appreciated.
Thanks & Regards,
Kinjal
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