NET high analysis of the "Revit API" beam

Source: Internet
Author: User

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&LT;KEYVALUEPAIR&LT;XYZ,Double>>>> Getbeamfloorspaircore (list<planarface> beambottomfaces, ienumerable<xyz> beamPoints, List<element>floors) {      varFloordatalist =NewList<keyvaluepair<element, LIST&LT;KEYVALUEPAIR&LT;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&LT;KEYVALUEPAIR&LT;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&LT;XYZ,Double>(projectpoint, distance); DataList.                                       ADD (pointanddistance);  Break;                                                }                                }                            }                        } }                    if(DataList! =NULL&&DataList. Any ()) {varFlooranddata =NewKeyvaluepair<element, LIST&LT;KEYVALUEPAIR&LT;XYZ,Double>>>(Floor, DataList);                    Floordatalist.add (Flooranddata); }                }           }     }     returnfloordatalist;}

NET high analysis of the "Revit API" beam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.