public result execute(externalcommanddata commanddata, ref string message, elementset elements)
document doc = uidoc.document;
//基於面的引用 doc.create.newfamilyinstance(face, xyz, xyz, symbol);
using (transaction ts = new transaction(doc, "bim"))
ts.start();
reference refer = uidoc.selection.pickobject(objecttype.element, "");
wall wall = doc.getelement(refer) as wall;
plana***ce pf = face as plana***ce;
xyz xyz = refer.globalpoint;
xyz = face.project(xyz).xyzpoint;
xyz normal = pf.facenormal;
//xyz normal = wall.orientation;
xyz refdir = normal.crossproduct(xyz.basisz);
familysymbol symbol = new filteredelementcollector(doc).ofclass(typeof(familysymbol)).ofcategory(builtincategory.ost_securitydevices).where(o => o.name == "左右通用").first() as familysymbol;
symbol.activate();
familyinstance instance = doc.create.newfamilyinstance(face, xyz, refdir, symbol);
ts.commit();
// 基於sketchplane
using (transaction tt = new transaction(doc, "bim"))
tt.start();
subtransaction sub = new subtransaction(doc);
sub.start();
plane plane = new plane(new xyz(1, 0, 0), xyz.zero);
sketchplane sp = sketchplane.create(doc, plane);
doc.activeview.sketchplane = sp;
doc.activeview.showactiveworkplane();
sub.commit();
level level=new filteredelementcollector(doc).ofclass(typeof(level)).orderby(o=>(o as level).projectelevation).first() as level;
familysymbol symbol = new filteredelementcollector(doc).ofclass(typeof(familysymbol)).ofcategory(builtincategory.ost_securitydevices).where(o => o.name == "左右通用").first() as familysymbol;
Revit 二次開發 元素的所有面
需要傳入乙個 options的物件 開啟的方式 options options new options options.computereferences true 確定是否計算對幾何物件的引用 options.includenonvisibleobjects true 是否提取未設定為可見的元素幾...
Revit二次開發 初學
前言 由於工作需要,近期開始學習revit二次開發知識。學習的同時將學習過程與小夥伴們一起分享,希望後來的小夥伴在看到我的學習筆記的時候有所幫助。說明由於revit的版本在不斷更新中,所以我在學習revit的時候選擇了從revit自帶的幫助檔案開始學習,不同版本的revit,就看相應的help檔案。...
revit二次開發之單位轉換
revit內部基本單位是英呎,如果要獲取或設定構件引數數值需要進行單位轉換,比如轉換為基本的公釐或公尺等單位 1.可以使用常規方式進行轉換 1英呎等於0.3047999995367公尺,等於304.7999995367公釐 2.可以使用revitapi內建的轉換函式進行目標單位的轉換 使用unitu...