Revit Family API add ry

Source: Internet
Author: User

First create a closed curve and then create an entity. here you need to manually draw a reference plane
[TransactionAttribute (Autodesk. Revit. Attributes. TransactionMode. Manual)]
Using createsolid: IExternalCommand
{
CurveArrArray createProfileLShape (Application _ rvtApp)
{

W = Util. mmToFeet (); d = Util. mmToFeet ();
Tw = Util. mmToFeet (); td = Util. mmToFeet ();

NVerts =;
XYZ [] pts = XYZ [] {
XYZ (-w/,-d /,),
XYZ (w/,-d /,),
XYZ (w/, (-d/) + td ,),
XYZ (-w/) + tw, (-d/) + td ,),
XYZ (-w/) + tw, d /,),
XYZ (-w/, d /,),
XYZ (-w/,-d /,)};
CurveArray pLoop = _ rvtApp. Create. NewCurveArray ();
(I =; I <nVerts; ++ I)
{
Line line = _ rvtApp. Create. NewLineBound (pts [I], pts [I +]);
PLoop. Append (line );
}

CurveArrArray pProfile = _ rvtApp. Create. NewCurveArrArray ();
PProfile. Append (pLoop );

PProfile;
}
Extrusion CreateSolid (Application app, Document doc)
{
CurveArrArray pProfile = createProfileLShape (app );
ReferencePlane pRefPlane = Util. findElement (doc, (ReferencePlane),) ReferencePlane;
SketchPlane pSketchPlane = doc. FamilyCreate. NewSketchPlane (pRefPlane. Plane );
DHeight = Util. mmToFeet ();
BIsSolid =;
Extrusion pSolid = doc. FamilyCreate. NewExtrusion (bIsSolid, pProfile, pSketchPlane, dHeight );
PSolid;
}
Result Execute (ExternalCommandData commandData, messages, ElementSet elements)
{
UIApplication app = commandData. Application;
Document doc = app. ActiveUIDocument. Document;

Transaction ts = Transaction (doc ,);
Ts. Start ();

FamilyManager m_familyMgr = doc. FamilyManager;

CreateSolid (app. Application, doc );


Ts. Commit ();

Result. Succeeded;
}
}
Util
{
MmToFeet (val) {val /;}
FeetToMm (val) {val *;}
Element findElement (Document _ rvtDoc, Type targetType, targetName)
{
FilteredElementCollector collector = FilteredElementCollector (_ rvtDoc );
Collector. WherePasses (ElementClassFilter (targetType ));

TargetElems = element collector element. Name. Equals (targetName) element;
List <Element> elems = targetElems. ToList <Element> ();

(Elems. Count>)
{Elems [];
}

;
}
Formatting and message handlers
Caption =;

InfoMsg (msg)
{

System. Diagnostics. Debug. WriteLine (msg );
WinForm. MessageBox. Show (msg, Caption, WinForm. MessageBoxButtons. OK, WinForm. MessageBoxIcon. Information );
}

ErrorMsg (msg)
{
WinForm. MessageBox. Show (msg, Caption, WinForm. MessageBoxButtons. OK, WinForm. MessageBoxIcon. Error );
}

} Url: http://greatverve.cnblogs.com/p/revit-family-api-create-solid.html

Related Article

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.