Hi.
How do I have to determine the reference of the four segments that make up the beam section in the section view .....
Sorry, I'm from VietNam so not good at english, I have to use google translate.
Thanks all..
Solved! Go to Solution.
Hi.
How do I have to determine the reference of the four segments that make up the beam section in the section view .....
Sorry, I'm from VietNam so not good at english, I have to use google translate.
Thanks all..
Solved! Go to Solution.
Solved by aignatovich. Go to Solution.
Hi!
This is dependent on your beam family geometry and section view position relative to beam position. Anyway you need to explore your beam geometry. You should get beamFamilyInstance symbol geometry with Options.ComputeReferences == true and find appropriate faces or edges. Explore faces normal with correlation to sectionview ViewDirection, RightDirection and UpDirection.
There is a simpler way if you use Revit 2018 and can prepare your family with named reference planes and get references via familyInstance.GetReferenceByName method
You may also look at http://thebuildingcoder.typepad.com/blog/2017/09/extentelem-and-square-face-dimensioning-references....
Hi!
This is dependent on your beam family geometry and section view position relative to beam position. Anyway you need to explore your beam geometry. You should get beamFamilyInstance symbol geometry with Options.ComputeReferences == true and find appropriate faces or edges. Explore faces normal with correlation to sectionview ViewDirection, RightDirection and UpDirection.
There is a simpler way if you use Revit 2018 and can prepare your family with named reference planes and get references via familyInstance.GetReferenceByName method
You may also look at http://thebuildingcoder.typepad.com/blog/2017/09/extentelem-and-square-face-dimensioning-references....
Thank you very much.
My beam is rectangular. I want the dimension of the beam width and height in cross section ....
I searched for a month and still have not found ....
I use Revit 2018 and C # language.
Thank you very much.
My beam is rectangular. I want the dimension of the beam width and height in cross section ....
I searched for a month and still have not found ....
I use Revit 2018 and C # language.
Look at this:
[Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiapp = commandData.Application; var uidoc = uiapp.ActiveUIDocument; var doc = uidoc.Document; var selectedBeam = uidoc .Selection .GetElementIds() .Select(doc.GetElement) .OfType<FamilyInstance>() .FirstOrDefault(); if (selectedBeam == null) return Result.Cancelled; var beamFaces = GetSolids(selectedBeam) .SelectMany(x => x.Faces.OfType<PlanarFace>()) .ToList(); var view = doc.ActiveView; var leftFace = beamFaces .FirstOrDefault(x => x.ComputeNormal(UV.Zero).IsAlmostEqualTo(-1*view.RightDirection)); var rightFace = beamFaces .FirstOrDefault(x => x.ComputeNormal(UV.Zero).IsAlmostEqualTo(view.RightDirection)); if (leftFace == null || rightFace == null) { message = "Can't create dimension"; return Result.Failed; } var shift = UnitUtils.ConvertToInternalUnits(500, DisplayUnitType.DUT_MILLIMETERS); var dimensionOrigin = selectedBeam.GetTotalTransform().Origin + shift * view.UpDirection; var dimensionLine = Line.CreateUnbound(dimensionOrigin, view.RightDirection); var dimensionReferences = new ReferenceArray(); dimensionReferences.Append(leftFace.Reference); dimensionReferences.Append(rightFace.Reference); using (var transaction = new Transaction(doc, "create dimension")) { transaction.Start(); doc.Create.NewDimension(view, dimensionLine, dimensionReferences); transaction.Commit(); } return Result.Succeeded; } private IEnumerable<Solid> GetSolids(Element element) { var geometry = element.get_Geometry(new Options {ComputeReferences = true}); return GetSolids(geometry) .Where(x => x.Volume > 0); } private static IEnumerable<Solid> GetSolids(IEnumerable<GeometryObject> geometryElement) { foreach (var geometry in geometryElement) { var solid = geometry as Solid; if (solid != null) yield return solid; var instance = geometry as GeometryInstance; if (instance != null) foreach (var instanceSolid in GetSolids(instance.GetSymbolGeometry())) yield return instanceSolid; var element = geometry as GeometryElement; if (element != null) foreach (var elementSolid in GetSolids(element)) yield return elementSolid; } } }
And the result for selected beam in section view:
For height dimension you should use UpDirection instead of RightDirection
Look at this:
[Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { var uiapp = commandData.Application; var uidoc = uiapp.ActiveUIDocument; var doc = uidoc.Document; var selectedBeam = uidoc .Selection .GetElementIds() .Select(doc.GetElement) .OfType<FamilyInstance>() .FirstOrDefault(); if (selectedBeam == null) return Result.Cancelled; var beamFaces = GetSolids(selectedBeam) .SelectMany(x => x.Faces.OfType<PlanarFace>()) .ToList(); var view = doc.ActiveView; var leftFace = beamFaces .FirstOrDefault(x => x.ComputeNormal(UV.Zero).IsAlmostEqualTo(-1*view.RightDirection)); var rightFace = beamFaces .FirstOrDefault(x => x.ComputeNormal(UV.Zero).IsAlmostEqualTo(view.RightDirection)); if (leftFace == null || rightFace == null) { message = "Can't create dimension"; return Result.Failed; } var shift = UnitUtils.ConvertToInternalUnits(500, DisplayUnitType.DUT_MILLIMETERS); var dimensionOrigin = selectedBeam.GetTotalTransform().Origin + shift * view.UpDirection; var dimensionLine = Line.CreateUnbound(dimensionOrigin, view.RightDirection); var dimensionReferences = new ReferenceArray(); dimensionReferences.Append(leftFace.Reference); dimensionReferences.Append(rightFace.Reference); using (var transaction = new Transaction(doc, "create dimension")) { transaction.Start(); doc.Create.NewDimension(view, dimensionLine, dimensionReferences); transaction.Commit(); } return Result.Succeeded; } private IEnumerable<Solid> GetSolids(Element element) { var geometry = element.get_Geometry(new Options {ComputeReferences = true}); return GetSolids(geometry) .Where(x => x.Volume > 0); } private static IEnumerable<Solid> GetSolids(IEnumerable<GeometryObject> geometryElement) { foreach (var geometry in geometryElement) { var solid = geometry as Solid; if (solid != null) yield return solid; var instance = geometry as GeometryInstance; if (instance != null) foreach (var instanceSolid in GetSolids(instance.GetSymbolGeometry())) yield return instanceSolid; var element = geometry as GeometryElement; if (element != null) foreach (var elementSolid in GetSolids(element)) yield return elementSolid; } } }
And the result for selected beam in section view:
For height dimension you should use UpDirection instead of RightDirection
Yeah...
I am very grateful to you......
Yeah...
I am very grateful to you......
Can't find what you're looking for? Ask the community or share your knowledge.