程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> 判斷鏈接文件偏移量創建空間。

判斷鏈接文件偏移量創建空間。

編輯:C#入門知識

start
[Transaction(TransactionMode.Manual)]
[Regeneration(RegenerationOption.Manual)]
  cmd : IExternalCommand
{
                              GetPath(List<> listPath,  strKey)
    {
         ( strPath  listPath)
        {
             (strPath.Contains(strKey))
                 strPath;
        }
         ;
    }
     Result Execute(ExternalCommandData cmdData,   msg, ElementSet elements)
    {
        UIDocument uiDoc = cmdData.Application.ActiveUIDocument;
        UIApplication uiApp = cmdData.Application;
        Document doc = uiDoc.Document;
        Selection selection = uiDoc.Selection;

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

        FilteredElementCollector collector =  FilteredElementCollector(doc);        collector.OfClass((Instance)).OfCategory(BuiltInCategory.OST_RvtLinks);        List<> listPath = GetLinkFilePaths(doc);
         (Element elDoc  collector)
        {
            Instance ins = elDoc  Instance;
             (ins != )
            {
                Transform transForm = ins.GetTransform();
                 strKey = elDoc.Name.Substring(, elDoc.Name.IndexOf());                Document docLink = uiApp.Application.OpenDocumentFile(GetPath(listPath, strKey));
                FilteredElementCollector collectorLink =  FilteredElementCollector(docLink);
                collectorLink.OfCategory(BuiltInCategory.OST_Rooms);
                 (Element el  collectorLink)
                {
                    Room room = el  Room;
                    LocationPoint roomPoint = room.Location  LocationPoint;
                    UV uv =  UV();
                     (room.Location != )
                    {
                        uv =  UV(roomPoint.Point.X + transForm.Origin.X, roomPoint.Point.Y + transForm.Origin.Y);
                    }
                    doc.Create.NewSpace(room.Level, uv);
                }
            }
        }
        ts.Commit();

         Result.Succeeded;
    }
                         List<> GetLinkFilePaths(Document doc)
    {
        List<> listPath =  List<>();
         (ElementId elId  ExternalFileUtils.GetAllExternalFileReferences(doc))
        {
             (doc.get_Element(elId).IsExternalFileReference())
            {
                ExternalFileReference fileRef = doc.get_Element(elId).GetExternalFileReference();
                 ( == fileRef.ExternalFileReferenceType.ToString())
                    listPath.Add(ModelPathUtils.ConvertModelPathToUserVisiblePath(fileRef.GetAbsolutePath()));
            }
        }
         listPath;
    }
}url:http://greatverve.cnblogs.com/p/revit-create-space.html

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved