Create 3D model curve from List<XYZ> in project document

Create 3D model curve from List<XYZ> in project document

Anonymous
Not applicable
4,489 Views
12 Replies
Message 1 of 13

Create 3D model curve from List<XYZ> in project document

Anonymous
Not applicable

Hi everyone,

I need to create a smooth curve that goes through some points defined by List<XYZ>. These points are not in the same plane. I can create the curve in the family document using CurveByPoints like the following:

curveByPts = document.FamilyCreate.NewCurveByPoints(refPtsAr);

However, it does not seem there is a corresponding method for the project document. How can I create a 3D model curve in the project document?

Thanks,

0 Likes
Accepted solutions (2)
4,490 Views
12 Replies
Replies (12)
Message 2 of 13

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @Anonymous ,

Is it possible via Revit UI?

because in Revit UI if it is possible then through Revit API you can achieve this functionality.

From my understanding, I think you can't extrude list of model curves in the project document.

However, You can use the model-in-place command but this command also opens the Revit family editor to create the extrusion.

 

I hope this helps.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 13

Revitalizer
Advisor
Advisor

Hi,

 

what about

 

ModelCurve mc = doc.Create.NewModelCurve(HermiteSpline.Create(points, false), sketchPlane);

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 13

Anonymous
Not applicable

 

Hi Revitalizer,

Thanks for your suggestions. But it still needs a Sketch Plane. In my case the points or the curve is not in a plane.

 

0 Likes
Message 5 of 13

Anonymous
Not applicable

 

Hi Naveen,

Thanks for your suggestions. I will try to create the curve in a family document and then import it into a project document.

 

0 Likes
Message 6 of 13

Revitalizer
Advisor
Advisor

Hi,

 

just define a new SketchPlane, on any Plane.

Since the Spline is 3D, none of the points need to reside in that Plane.

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 7 of 13

Anonymous
Not applicable

 

Hi Revitalizer,

Thanks. I tried the method by defining an arbitrary plane and got an exception “Curve must be in the plane”

 

0 Likes
Message 8 of 13

Revitalizer
Advisor
Advisor

Hi,

 

the solution is not to create a HermiteSpline but a NurbSpline:

 

https://forums.autodesk.com/t5/revit-api-forum/how-to-draw-modelnurbspline/m-p/7500615

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes
Message 9 of 13

Anonymous
Not applicable

Hi, 

But a NurbSpline must lie in a plane. 

Message 10 of 13

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

okay, okay.

 

I really think there is no need for creating a Family and placing that into the project just for drawing a 3D curve.

WireframeBuilder builder = new WireframeBuilder();

List<XYZ> points = new List<XYZ>();

points.Add(new XYZ(0, 0, 0));
points.Add(new XYZ(10, 0, 0));
points.Add(new XYZ(10, 10, 0));
points.Add(new XYZ(0, 10, 0));

points.Add(new XYZ(0, 0, 5));
points.Add(new XYZ(10, 0, 5));
points.Add(new XYZ(10, 10, 5));
points.Add(new XYZ(0, 10, 5));

points.Add(new XYZ(0, 0, 10));
points.Add(new XYZ(10, 0, 10));
points.Add(new XYZ(10, 10, 10));
points.Add(new XYZ(0, 10, 10));


builder.AddCurve(HermiteSpline.Create(points, false));

ElementId categoryId = new ElementId(BuiltInCategory.OST_GenericModel);

DirectShape ds = DirectShape.CreateElement(doc, categoryId);

ds.SetShape(builder);

ds.Name = "Helix";

WireframeHelix.png

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





Message 11 of 13

Anonymous
Not applicable

 

Hi Revitalizer,

It works great. Thanks.

 

0 Likes
Message 12 of 13

Anonymous
Not applicable

how exactly can this be used? Is it possible to simply make this into a button that, for example, takes a formatted .txt file of coordinate and make a 3d model curve in the project?

0 Likes
Message 13 of 13

Revitalizer
Advisor
Advisor

Hi,

 

please use something like this:

 

https://thebuildingcoder.typepad.com/blog/2013/10/text-file-driven-automatic-placement-of-family-ins...

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes