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: 

Something thats getting on my NURBS

2 REPLIES 2
Reply
Message 1 of 3
DavidIntVeld
444 Views, 2 Replies

Something thats getting on my NURBS

Hi,

 

For fun and educational purposes I'm trying to create a little application that will let the users build a little bridge over a river.

 

The structural members I want to generate using a formula, any custom formula a user tweeks. 

 

Now to "build" this bridge in Revit I am now trying to find the right approach to put this into code. 

First choise would be using nurbsplines.

 

I found this bit of link of course:

http://thebuildingcoder.typepad.com/blog/2009/06/creating-a-curved-beam.html

 

And the links that it refers to, are interesting links... 

 

In any ways, the link refers to 2009 and after this not much has been written on the nurbspline class....

 

So I created this little code.

which creates the arch as shown below.

 

Curve c = CreateNurbSpline(doc);
FamilyInstance inst =
   doc.Create.NewFamilyInstance(
   c,
   targetElems.ElementAt(0),
   level,
   StructuralType.Beam);

 Then:

 

        NurbSpline CreateNurbSpline(Document doc)
        {
            //Appvars
            int n = 80;
            double length = 25000 / ft;
            double width = 5000 / ft;

            IList<XYZ> PointsList = new List<XYZ>();
            IList<double> WeightList = new List<double>();

            //StartingSubPoint taken from insertionpoint family
            XYZ p1 = new XYZ(
                    StartingSubPoint.X + 25, //Offset might be required
                    StartingSubPoint.Y,
                    StartingSubPoint.Z);

            //XYZ CurrentPoint = StartingSubPoint;
            PointsList.Add(p1);
            WeightList.Add(1);

            for (int i = 0; i < n; i++)
            {
                //Repeat untill end of formula is reached.(creates n-1 points)
                XYZ p2 = new XYZ(
                    p1.X + (width / n), //works
                    //StartingSubPoint.X + Math.Sin(a) * 2, //doesnt work
                    p1.Y + (length / n), //works
                    StartingSubPoint.Z + Math.Sin(a) * 10);

                //Add Controlpoint to list
                PointsList.Add(p2);
                WeightList.Add(1);

                //Start from where we left for the next round
                p1 = p2;

                //Next point on curve we only run "top curve of sin formula"
                a += ((Math.PI) / n);
            }

            NurbSpline detailNurbSpline
              = NurbSpline.Create(PointsList, WeightList);

            return detailNurbSpline;

        }

 

However all the examples, and the code above create a 2D Nurbsplines,

I would like to be able to shape my arches in three dimensions.

 

Is this at all possible using Nurbs? Nowhere I can find that I cant.

if I replace the part:

 

p1.X + (width / n), //works

 

with:

 

StartingSubPoint.X + Math.Sin(a) * 2,

 

the loop will run over two axes creating 3 dimensional spline.

If I try I get this:

 

Error.jpg

 

----------

 

I can build the arch using short segments of staight lines, and I am able to more freely build lines as shown below:

 

Isometric View On Sweeps.jpg

 

 

Top View On Sweeps.jpg

 

 

But this takes much longer and often create problems when the beams join.

 

So is there a way to create a 3D Nurb (meaning using all three axes)?

 

Thanks

 

 

 

 

 

 

 

 

2 REPLIES 2
Message 2 of 3
jeremytammik
in reply to: DavidIntVeld

Dear David,

 

Thank you for you nice and interesting query.

 

I am checking with the development team.

 

Cheers,

 

Jeremy



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

Message 3 of 3
jeremytammik
in reply to: DavidIntVeld

Dear David,

 

I heard back from the development team, and they say:

 

It looks like the problem is not with creating the 3D NURBS, it's with using them for the purpose of creating a Revit element. Are you creating a curve-driven family instance? We can only guess by looking at the error message, although you don't explicitly mention the code that results in the error.

 

You might be able to do it by creating the geometry directly in a family. For example, use the Mass family element NewLoftForm or NewSweptBlendForm creation routines.

 

I hope this helps.

 

Best regards,

 

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