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.
private static XYZ GetPointAt(CurveByPoints modelcurve, double a) { Curve geomE = modelcurve.GeometryCurve; XYZ paramPnt = geomE.Evaluate(a, true); return paramPnt; }
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.
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.
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
Nope, it does the same thing.
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.
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.