The principle is to take a point from the locationcurve of the beam and then project it to the upper surface of the plate. If there is a projection point, and then projected from the projection point (on the plate) to the bottom of the beam, the distance can be obtained if there is a projection point.
The first condition of using this analysis is that the beam is above the plate, do not forget!
varBeambottomfaces =faceutils.getbottomfaces (beam); //This method is self-encapsulated if(NULL! = Beambottomfaces &&Beambottomfaces.any ()) { varBeamlocationcurve = Beam. Location asLocationcurve; varBeamcurve =Beamlocationcurve.curve; if(Beamcurve! =NULL) { if(Beamcurve isLine ) {Beamcurve=Getextlocationcurve (Beamcurve); //If Locationcurve is line, it is best to do an extension algorithm, or some beams because of deductions, Locationcurve easily missing part } varBeampoints =getpoints (Beamcurve, Pointrange); //pointrange is the pickup interval. if(Beampoints! =NULL&&Beampoints.any ()) { varFloordatalist =Getbeamfloorspaircore (beambottomfaces, beampoints, floors); //floors for building boards } }}
Extension of Locationcurve:
Private Curve Getextlocationcurve (Curve Curve) { = XYZ. Zero; = XYZ. Zero; if is Line ) { as line ). Direction.negate (); as Line ). Direction; } = Line.createbound (curve. Getendpoint (0) + 1E3 * dir0, Curve. Getendpoint (1) + 1E3 * dir1); return Extcurve;}
On curve, press Pointrange to select a point:
PrivateList<xyz> getpoints (Curve Curve,DoublePointrange) { varPoints =NewList<xyz>(); varBeamlength =curve. Length; varPointsnumber = beamlength% Pointrange = =0? ((Beamlength/pointrange)-1): Math.floor ((Beamlength/pointrange)); for(vari =1; I <= Pointsnumber; i++) { varPoint = Curve. Evaluate (Pointrange * I,false); Points. ADD (point); } returnpoints;}
Get Distance:
PrivateList<keyvaluepair<element, LIST<KEYVALUEPAIR<XYZ,Double>>>> Getbeamfloorspaircore (list<planarface> beambottomfaces, ienumerable<xyz> beamPoints, List<element>floors) { varFloordatalist =NewList<keyvaluepair<element, LIST<KEYVALUEPAIR<XYZ,Double>>>>(); //look for the plates under each structure beam foreach(varFloorinchconstructionfloors) { //gets the top point coordinates of the board varFloortopfaces =faceutils.gettopfaces (floor); if(NULL! = Floortopfaces &&Floortopfaces.any ()) { varDefaultfloororiginz =Floortopfaces.firstordefault (). Origin.z; foreach(varTfinchfloortopfaces) { varOriginz =TF. Origin.z; if(Defaultfloororiginz <=Originz) {Defaultfloororiginz=Originz; } } varDefaultbeamoriginz =Beambottomfaces.firstordefault (). Origin.z; foreach(varBfinchbeambottomfaces) { varOriginz =BF. Origin.z; if(Defaultbeamoriginz >=Originz) {Defaultbeamoriginz=Originz; } } //the plate is below the beam . varIslower = Defaultfloororiginz <Defaultbeamoriginz; if(islower) {varDataList =NewLIST<KEYVALUEPAIR<XYZ,Double>>(); //a point on the beam can be projected onto the board. foreach(varPointinchbeampoints) { foreach(varTfinchfloortopfaces) { varIsproject =TF. Project (point); if(NULL!=isproject) { //the coordinates of the points projected onto the board varProjectpoint =Isproject.xyzpoint; //the distance from the projection point to the point on the beam foreach(varBfinchbeambottomfaces) { varbp =BF. Project (Projectpoint); if(NULL!=BP) { varDistance =BP. Distance; Distance=unitutils.convertfrominternalunits (distance, displayunittype.dut_millimeters); Distance=Math.floor (distance); varPointanddistance =NewKEYVALUEPAIR<XYZ,Double>(projectpoint, distance); DataList. ADD (pointanddistance); Break; } } } } } if(DataList! =NULL&&DataList. Any ()) {varFlooranddata =NewKeyvaluepair<element, LIST<KEYVALUEPAIR<XYZ,Double>>>(Floor, DataList); Floordatalist.add (Flooranddata); } } } } returnfloordatalist;}
NET high analysis of the "Revit API" beam