How to programmatically create a line in Revit that is less than 0.8mm in length

Source: Internet
Author: User



Revit does not know why there is a strange rule that it is impossible to draw a line of length less than 0.8mm in length. (0.8mm equals 32 of one inch). Cause a lot of small short lines cannot be drawn.

In light steel thin-walled member, its thickness is only 0.5, some 0.7, can not be drawn. This brings some limitations to Revit's work.

Here is a programmatic way to create less than 0.8mm, and its usage is a bit hard to think of.

First we create a long line with a length magnification of 100 times times. Then add a dimension constraint to the line and bind to a parameter. Finally, the value of the specified parameter is the actual length. Finally, the standard and temporary parameters are removed. This makes it possible to draw lines that are less than 0.8mm in length.

The following is a code demonstration. Everyone can see for themselves.

[Autodesk.Revit.Attributes.Transaction (Autodesk.Revit.Attributes.TransactionMode.Manual)]class Rvttestcommand:  iexternalcommand{//member variables for top level access to the REVIT database//public application _app;  Public Document M_doc;  String barefamilyname = "Type1"; Command main/Public Result Execute (externalcommanddata commanddata, ref string message, ElementSet Eleme    NTS) {_app = commandData.Application.Application;    M_doc = commandData.Application.ActiveUIDocument.Document;    UIApplication m_revit = commanddata.application;    Transaction trans = new Transaction (M_doc); Trans.    Start ("Crateshortline"); DrawLine (_app. Create, M_doc, M_doc.       ActiveView, True, new XYZ (0.00087971/304.8, 4.85813270/304.8, 0), new XYZ (0.34120938/304.8, 4.18071790/304.8, 0));    Trans.commit ();  return result.succeeded;  } public XYZ Getendpoint (Curve C, int index) {return c.getendpoint (index); Reference getendpointreference (Curve C, inT index) {return c.get_endpointreference (index);  } public double Mmtofeet (double mm) {return mm/304.8; } public void DrawLine (Autodesk.Revit.Creation.Application appcreate, Document famdoc, View workview,bool Bonxyplane, X    YZ StartPoint, xyz endPoint) {xyz _offset = new XYZ (0, 0, 0);    Double dlength = Startpoint.distanceto (endPoint);      if (Dlength < 1/32.0/12.0) {if (dlength = = 0) {return;  } else if ((Dlength *) < 1/32.0/12.0) {taskdialog.show ("Lengh check", "line too small to draw,      Even when multiplied by 100 ");          } else {try {XYZ ptvector = Endpoint-startpoint;          XYZ ptmultiplied = startPoint + ptvector * 100;          Line revitline = Appcreate.newlinebound (ptmultiplied + _offset, StartPoint + _offset);          Detailline detailLine2 = FamDoc.FamilyCreate.NewDetailCurve (Workview, revitline) as Detailline; XYZ pttempline = startPoint + NEW XYZ (Mmtofeet (2.0), Mmtofeet (1.855), 0);          Line revitlinetemp = Appcreate.newlinebound (Pttempline + _offset, StartPoint + _offset);                    Detailline detaillinetemp = FamDoc.FamilyCreate.NewDetailCurve (Workview, revitlinetemp) as Detailline;          Famdoc.regenerate ();            try {//dimension of whole length Referencearray Refarray = new Referencearray ();            Refarray.append (getendpointreference (detailline2.geometrycurve, 0));            Refarray.append (Getendpointreference (Detailline2.geometrycurve, 1)); XYZ P1 = new xyz (getendpoint (revitline, 0). X + 0.1, getendpoint (revitline, 0). Y + 0.1, getendpoint (revitline, 0).            Z); XYZ P2 = new xyz (Getendpoint (Revitline, 1). X + 0.1, Getendpoint (Revitline, 1). Y + 0.1, Getendpoint (Revitline, 1).            Z);            Line line = Appcreate.newlinebound (P1, p2); DimeNsion dimensiontotal = famDoc.FamilyCreate.NewLinearDimension (Workview, line, Refarray);            Familyparameter famParamL1 = FamDoc.FamilyManager.get_Parameter ("Smalllinelength"); try {if (famParamL1 = = null) {famParamL1 = FamDoc.FamilyManager.AddP              Arameter ("Smalllinelength", Builtinparametergroup.pg_general, Parametertype.length, true); } if (famDoc.FamilyManager.Types.Size = = 0) {FamDoc.FamilyManager.NewType (this.b              Arefamilyname);              } famDoc.FamilyManager.Set (FamParamL1, dlength);                         Dimensiontotal.familylabel = famParamL1; FamDoc.FamilyManager.Set (famParamL1, dlength); needed to make it resize properly} finally {Famdoc.delete (Dimensiontota L.id); Now remove the dimension, no longer needed famDoc.FamilyManager.RemoveParameter (famParamL1); Now remove the parameter, no longer needed}} finally {Famdoc.delete (deta          Illinetemp.id); }} catch (System.Exception Exception) {taskdialog.show ("Exception", Exception.        Message);  }}} else {try {line revitline = Appcreate.newlinebound (StartPoint + _offset, EndPoint +        _offset);      Detailline detailLine2 = FamDoc.FamilyCreate.NewDetailCurve (Workview, revitline) as Detailline; } catch (System.Exception Exception) {taskdialog.show ("Exception", Exception.      Message); }    }  }}


Sativus into Autodesk Development consulting experts, Olive Mountain Software chief research and Development reprint please indicate the original source. http://blog.csdn.net/joexiongjin/article/details/42003917


How to programmatically create a line in Revit that is less than 0.8mm in length

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.