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: 

Continuous beam over curved line, a study

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
997 Views, 3 Replies

Continuous beam over curved line, a study

Hi,

This is not much of a question of what or how, but more of why. I solved the problem, but I don’t understand why. A while ago I tried to draw curved beams in a way that was impossible.

(This is a follow up post of an old post of mine when I tried to generate some beams on a curved line. http://forums.autodesk.com/t5/revit-api/something-thats-getting-on-my-nurbs/m-p/5425585/highlight/tr... )

In between I got married and had a child, and didn’t had much spare time to follow up on this. But a few weeks ago I had to pick up where I left because of a project.

The main goal is to “free-flow” draw beams based on a list of coordinates that a user can load from a txt file, by formula or by inserting “guide“ points in a drawing. As pointed out in the previous post; Beams can only exist as flat line objects, unless you would draw it as a mass…

I created a class that draws beams over any line imaginable by doing a bit of a trick.

  1. I load a list of coordinates into a list (let’s say 20 points). These will be the path of the beams, but for Arc’s I need much more points for the midpoints to make the structure smooth… SO:


    001_InterFace.JPG

  2. I generate out of these points a mass family (on the background), where I create a CurveByPoints that follows these points.(see code below)
  3. I can then iterate over this generated line and get much more coordinates to make my construction more smooth and detailed.

            private static XYZ GetPointAt(CurveByPoints modelcurve, double a)
            {
                Curve geomE = modelcurve.GeometryCurve;
                XYZ paramPnt = geomE.Evaluate(a, true);
                            
                return paramPnt;
            }

    (where a is a value between 0 and 1)
  4. Next I get let’s say 100 points and use these for ends and midpoints to generate arc beams
  5. I draw the beams using 

  6.             FamilyInstance curvedBeam =
                doc.Create.NewFamilyInstance(
                ArchCurve,
                BeamProfile,
                level,
                StructuralType.Beam);


This results in indeed a nicely curved beam. But at some places the beams seem to “flip”. As default the beams seem to be drawn with y and z justification to top / centre, and causes the beams to flip where the orientation changes. This kind of makes sense since relative to the plane, the bottom and top changes. But when I select the beam it is impossible to change these justifications through the user interface. They “stick” to the drawn alignment.

 

002_Result.JPG

 

 

 

003_Element_z justification Centre.JPG

No problem; we change the justifications through the API directly after the beam is created. Voila: this works! All beams align. We can draw some pretty shapes now! But still no way the justifications can be changed after creation.

Is this because the beam is on a funny angle?  Or is this because it was created through the API and somehow “locks” these? Also the fact that these are concrete beams matter. Steel beams I made that are not allowed to join can be changed later.

 

004_Element Justification Centred Correctly.JPG

 

 

Anyways, while writing this post, and trying many things not to miss something obvious and waste your time, I got it kind of fixed already… But still it’s a bit of strange Revit / API behaviour I can’t really get my head around. I never noticed this in normal Revit behaviour… I wanted to create a simple script and leave it to the user to modify / fix any small errors later, but it seems I need a bit more input from the user now and control it through the script.. 

 

 

Anyways to share the findings here are some scrips:

 

This creates the curved line by point in a family 

 

 

        internal static CurveByPoints MakeSweepLineInFamily(Autodesk.Revit.DB.Document fdoc, IList<XYZ> MyPath)
        {
            Autodesk.Revit.Creation.Application CreaApp = fdoc.Application.Create;
            
            //Set line to a plane on 0,0,0
            XYZ norm = Autodesk.Revit.DB.XYZ.BasisZ;
            XYZ flat = new XYZ(1,1,0);
            Plane plane = CreaApp.NewPlane(norm, norm);
            SketchPlane skplane = SketchPlane.Create(fdoc, plane);

            //Start building the path
            ReferencePointArray pointlist = CreaApp.NewReferencePointArray();
            ReferencePoint refPoint = null;

            foreach (XYZ point in MyPath)
            {
                refPoint = fdoc.FamilyCreate.NewReferencePoint(point);
                refPoint.Position = point;
                refPoint.Visible = true;

                pointlist.Append(refPoint);
                                
            }

            CurveByPoints modelcurve = fdoc.FamilyCreate.NewCurveByPoints(pointlist);
            return modelcurve;
        }

 

This draws the beam and sets the orientation

 

 

        public void DrawArch(UIApplication app, XYZ p1, XYZ pm, XYZ p2, FamilySymbol BeamProfile, bool centre = false, bool dissalowjoin = false)
        {
            //Appvars
            UIDocument uidoc = app.ActiveUIDocument;
            Document doc = uidoc.Document;

            Arc ArchCurve = Arc.Create(p1, p2, pm);

            Level level = app.ActiveUIDocument.Document.ActiveView.GenLevel;

            FamilyInstance curvedBeam =
            doc.Create.NewFamilyInstance(
            ArchCurve,
            BeamProfile,
            level,
            StructuralType.Beam);

            LocationCurve locationCurve = curvedBeam.Location as LocationCurve;
            locationCurve.Curve = ArchCurve;

            if (centre == true)
            {
                Parameter paramz = curvedBeam.LookupParameter("z Justification");
                paramz.Set(1);
                Parameter paramy = curvedBeam.LookupParameter("y Justification");
                paramy.Set(1);
            }

            if(dissalowjoin == true)
            {
                if (curvedBeam.StructuralMaterialType.ToString() == "Steel")
                {
                    StructuralFramingUtils.DisallowJoinAtEnd(curvedBeam, 0);
                    StructuralFramingUtils.DisallowJoinAtEnd(curvedBeam, 1);
                }
            }


        }

 

Thanks

 

 

 

 

 

 

 

 

3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Are the points defining the curves for the beams that flip ordered in clock-wise order by any chance? Try sorting the points into ccw order before creating the curves and see if that helps.
Message 3 of 4
Anonymous
in reply to: Anonymous

Nope, it does the same thing.

 

005_CCW.JPG

 

 

But its a joining issue, the moment I dissalow join I can edit them savely.

So i should always dissalow join on all the beams...but it can result in funny gaps for concrete structure thou.

 

 

Message 4 of 4
Anonymous
in reply to: Anonymous

Dear DavidIntVeld,

 

First, i would like to thank you for your work here, it's very complicated to find some serious information about non planar curved beam.

I'm working on a project which need to generate a beam with non planar curve but i'm struggling with the mass family (a.k.a. AdapativeComponent ?) 

 

Can you detail a little bit more about the generation of a mass family in background ? (Family creation in real-time, point data transmission etc.)

 

Regards.

 

P.S. : Be very kind with my english, i'm french.

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

Post to forums  

Forma Design Contest


Rail Community