[Grasshopper]場地建築體塊生成(Updata)
每次看到大家擼SU場地模型就感覺特別憂傷。然後就給大家推薦了jackieyin大神的Surrounding Builder插件~~~場地模型自動生成插件(Surrounding Builder) - NCF參數化建築論壇
但是奈何大神的插件還是有一定的BUG,用起來不是那麼爽。
所以我就重新寫了一個生成場地的小工具~~~
這個工具由兩部分組成
Part 1:
拾取數據
詳細代碼借鑒此文[Grasshopper]地形生成(Updata)
Part 2:
處理文本數據
這部分針對不同的CAD底圖有不同方法,仁者見智,就不講了
Part 3:
生成體塊Code如下
List<Curve> curveincludepoint = new List<Curve>();n List<List<int>> list10 = new List<List<int>>();n List<int> list8 = new List<int>();nn foreach (Curve curve in curvelist)n {n if (!curve.IsPlanar())n {n System.Console.Write("The outline input is not planar curve!");n }n }n foreach (Curve curve2 in curvelist)n {n if (curve2.IsClosed)n {n for (int i = 0; i < Pointlist.Count; i++)n {n PointContainment pointContainment = curve2.Contains(Pointlist[i]);n if (pointContainment == PointContainment.Inside)n {n list8.Add(i);n }n }n if (list8.Count != 0)n {n curveincludepoint.Add(curve2);n }n }n }n List<int> includedpoint = list8.Distinct().ToList();nn List <List<int>> listnum = new List <List<int>>();n List <List<Curve>> listmapcurve = new List <List<Curve>>();n foreach (int i in includedpoint)n {n List < int > nums = new List<int>();n List < Curve > mapcurve = new List < Curve >();n foreach (Curve curve in curveincludepoint)n {n PointContainment pointContainment2 = curve.Contains(Pointlist[i]);n if (pointContainment2 == PointContainment.Inside)n {n nums.Add(i);n mapcurve.Add(curve);n }n }n listnum.Add(nums);n listmapcurve.Add(mapcurve);n }nn List <int> listnumout = new List <int>();n List <Curve> listmapcurveout = new List <Curve>();n List <Point3d> listpointout = new List <Point3d>();n List <int> listtextout = new List <int>();nn for (int j = 0;j < listnum.Count; j++)n {n List < double > areas = new List< double >();n for(int k = 0;k < listmapcurve[j].Count;k++)n {n AreaMassProperties areaMassProperties = AreaMassProperties.Compute(listmapcurve[j][k]);n areas.Add(areaMassProperties.Area);n }n List< double > areassort = new List< double >(areas);n areassort.Sort();n double q = areassort[0];n int m = areas.IndexOf(q);n listmapcurveout.Add(listmapcurve[j][m]);n listnumout.Add(listnum[j][m]);n listpointout.Add(Pointlist[listnum[j][m]]);n listtextout.Add(Textlist[listnum[j][m]]);n }nn Curve = listmapcurveout;n Point = listpointout;n Text = listtextout;n Number = listnumout;n
運行結果如下:
如果需要合併體塊請自行Union~~
下面是打包的文件的下載:(這個支持了自動處理被切碎的CAD圖的建築輪廓的自動閉合)
下載鏈接:http://pan.baidu.com/s/1cg24f8
歡迎各位下載~~
推薦閱讀:
※Dynamo應用秘籍:18:與Revit圖形數據交互
※Dynamo應用秘籍:7:Revit地形到Dynamo的Surface
※Dynamo應用秘籍:8:Revit地形到Dynamo的Solid
※Dynamo應用秘籍:10:使用周期性運行製作動畫演示