LOGO挤出
This commit is contained in:
@@ -20,27 +20,56 @@ namespace RookieStation
|
||||
UIDocument uidoc = uiapp.ActiveUIDocument;
|
||||
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
|
||||
Document doc = uidoc.Document;
|
||||
var instances = new FilteredElementCollector(doc).OfClass(typeof(ImportInstance)).Cast<ImportInstance>();
|
||||
//var instances = new FilteredElementCollector(doc).OfClass(typeof(ImportInstance)).Cast<ImportInstance>();
|
||||
List<Curve> curves = new List<Curve>();
|
||||
|
||||
var geometryElement = instances.First().get_Geometry(new Options());
|
||||
|
||||
foreach (var geomObj in geometryElement)
|
||||
ImportInstance importInstance = null;
|
||||
string familyfilename = string.Empty;
|
||||
//var geometryElement = instances.First().get_Geometry(new Options());
|
||||
try
|
||||
{
|
||||
GeometryInstance geometryInstance = geomObj as GeometryInstance;
|
||||
if (geometryInstance != null)
|
||||
var importRefer = uidoc.Selection.PickObject(ObjectType.Element, new SelectFilter<ImportInstance>(), "请选择CAD图块");
|
||||
importInstance = doc.GetElement(importRefer) as ImportInstance;
|
||||
string s = importInstance.Category.Name;
|
||||
familyfilename = s.Substring(0, s.LastIndexOf("."));
|
||||
var geometryElement = importInstance.get_Geometry(new Options());
|
||||
foreach (var geomObj in geometryElement)
|
||||
{
|
||||
foreach (var instObj in geometryInstance.GetSymbolGeometry())
|
||||
GeometryInstance geometryInstance = geomObj as GeometryInstance;
|
||||
if (geometryInstance != null)
|
||||
{
|
||||
Curve curve = instObj as Curve;
|
||||
if (curve == null)
|
||||
foreach (var instObj in geometryInstance.GetSymbolGeometry())
|
||||
{
|
||||
continue;
|
||||
Curve curve = instObj as Curve;
|
||||
if (curve != null)
|
||||
{
|
||||
curves.Add(curve);
|
||||
}
|
||||
PolyLine polyLine = instObj as PolyLine;
|
||||
if (polyLine != null)
|
||||
{
|
||||
var points = polyLine.GetCoordinates();
|
||||
for (int i = 0; i < points.Count - 1; i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
Line line = Line.CreateBound(points[i], points[i + 1]);
|
||||
curves.Add(line);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
curves.Add(curve);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
||||
{
|
||||
return Result.Cancelled;
|
||||
}
|
||||
|
||||
//doc.Invoke(ts =>
|
||||
//{
|
||||
// foreach (var curve in curves)
|
||||
@@ -51,60 +80,80 @@ namespace RookieStation
|
||||
//});
|
||||
CurveArrArray arrArray = new CurveArrArray();
|
||||
CurveArray array = new CurveArray();
|
||||
|
||||
SearchCurveConnected(curves, curves.FirstOrDefault(), array, arrArray);
|
||||
//do
|
||||
//{
|
||||
// Curve baseCurve = curves.Last();
|
||||
// var tempEndXyz = baseCurve.GetEndPoint(1);
|
||||
// array.Clear();
|
||||
// array.Append(baseCurve);
|
||||
// curves.Remove(baseCurve);
|
||||
|
||||
// for (int j = curves.Count - 1; j >= 0; j--)
|
||||
// {
|
||||
// Curve tempCurve = curves[j];
|
||||
|
||||
// if (tempCurve.GetEndPoint(0).IsAlmostEqualTo(tempEndXyz))
|
||||
// {
|
||||
// baseCurve = tempCurve;
|
||||
// tempEndXyz = tempCurve.GetEndPoint(1);
|
||||
// array.Append(tempCurve);
|
||||
// curves.Remove(tempCurve);
|
||||
// continue;
|
||||
// }
|
||||
// else if (tempCurve.GetEndPoint(1).IsAlmostEqualTo(tempEndXyz))
|
||||
// {
|
||||
// baseCurve = tempCurve;
|
||||
// tempEndXyz = tempCurve.GetEndPoint(0);
|
||||
// array.Append(tempCurve);
|
||||
// curves.Remove(tempCurve);
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// arrArray.Append(array);
|
||||
//} while (curves.Count > 0);
|
||||
|
||||
doc.Invoke(ts =>
|
||||
if (curves.Count == 0)
|
||||
{
|
||||
SketchPlane plane = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero));
|
||||
return Result.Failed;
|
||||
}
|
||||
SearchCurveConnected(curves, curves.FirstOrDefault(), array, arrArray);
|
||||
string rftPath = app.FamilyTemplatePath + "\\概念体量\\公制体量.rft";
|
||||
|
||||
foreach (CurveArray arr in arrArray)
|
||||
Document faDoc = app.NewFamilyDocument(rftPath);
|
||||
|
||||
doc.InvokeGroup(tg =>
|
||||
{
|
||||
faDoc.Invoke(ts =>
|
||||
{
|
||||
var ml = doc.FamilyCreate.NewModelCurveArray(arr, plane);
|
||||
}
|
||||
//foreach (CurveArray arr in arrArray)
|
||||
//{
|
||||
// doc.FamilyCreate.NewExtrusion(true, arrArray, plane, 5.0 / 304.8);
|
||||
SketchPlane plane = SketchPlane.Create(faDoc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero));
|
||||
|
||||
// //var ml = doc.FamilyCreate.NewModelCurveArray(arr, plane);
|
||||
//}
|
||||
List<CurveLoop> cls = new List<CurveLoop>();
|
||||
foreach (CurveArray arr in arrArray)
|
||||
{
|
||||
ReferenceArray referenceArray = new ReferenceArray();
|
||||
foreach (Curve curve in arr)
|
||||
{
|
||||
var ml = faDoc.FamilyCreate.NewModelCurve(curve, plane);
|
||||
referenceArray.Append(ml.GeometryCurve.Reference);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
faDoc.FamilyCreate.NewExtrusionForm(true, referenceArray, new XYZ(0, 0, 10 / 304.8));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//TaskDialog.Show("温馨提示", "实体无法创建");
|
||||
//TaskDialog.Show("温馨提示", ex.Message + "\n\r" + ex.InnerException.ToString());
|
||||
continue;
|
||||
}
|
||||
|
||||
//var ml = doc.FamilyCreate.NewModelCurveArray(arr, plane);
|
||||
//foreach (ModelCurve c in ml)
|
||||
//{
|
||||
// referenceArray.Append(c.GeometryCurve.Reference);
|
||||
//}
|
||||
}
|
||||
|
||||
//foreach (CurveArray arr in arrArray)
|
||||
//{
|
||||
// var ml = doc.FamilyCreate.NewModelCurveArray(arr, plane);
|
||||
// //doc.FamilyCreate.NewExtrusion(true, arrArray, plane, 5.0 / 304.8);
|
||||
//}
|
||||
});
|
||||
Family fa = faDoc.LoadFamily(doc);
|
||||
|
||||
faDoc.Close(false);
|
||||
|
||||
doc.Invoke(ts =>
|
||||
{
|
||||
if (fa != null)
|
||||
{
|
||||
FamilySymbol familySymbol = doc.GetElement(fa.GetFamilySymbolIds().FirstOrDefault()) as FamilySymbol;
|
||||
fa.Name = familyfilename;
|
||||
familySymbol.Name = familyfilename;
|
||||
if (familySymbol.IsActive == false)
|
||||
{
|
||||
familySymbol.Activate();
|
||||
}
|
||||
doc.Create.NewFamilyInstance(importInstance.GetTransform().Origin, familySymbol, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return Result.Succeeded;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 找到所有连接在一起的线圈并分好组
|
||||
/// 递归找到所有连接在一起的线圈并分好组
|
||||
/// </summary>
|
||||
/// <param name="curves">所有线</param>
|
||||
/// <param name="initcurve">用于查找与其连接的初始线</param>
|
||||
@@ -116,17 +165,21 @@ namespace RookieStation
|
||||
{
|
||||
Curve tempCurve = curves[i];
|
||||
var baseEndXyz = initcurve.GetEndPoint(0);
|
||||
//把初始的第一个添加进集合
|
||||
if (curveArrArray.Size == 0)
|
||||
{
|
||||
curveArrArray.Append(initCurveArray);
|
||||
}
|
||||
if (tempCurve.GetEndPoint(0).IsAlmostEqualTo(baseEndXyz) || tempCurve.GetEndPoint(1).IsAlmostEqualTo(baseEndXyz))
|
||||
{
|
||||
initCurveArray.Append(tempCurve);
|
||||
curves.Remove(tempCurve);
|
||||
SearchCurveConnected(curves, tempCurve, initCurveArray, curveArrArray);
|
||||
|
||||
return;
|
||||
}
|
||||
else if (i == curves.Count() - 1)
|
||||
//遍历完一个线串时
|
||||
if (i == curves.Count() - 1)
|
||||
{
|
||||
curveArrArray.Append(initCurveArray);
|
||||
//curveArrArray.Append(initCurveArray);
|
||||
//array.Clear();
|
||||
initCurveArray = new CurveArray();
|
||||
SearchCurveConnected(curves, curves.FirstOrDefault(), initCurveArray, curveArrArray);
|
||||
@@ -135,7 +188,6 @@ namespace RookieStation
|
||||
{
|
||||
curveArrArray.Append(initCurveArray);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,23 +28,31 @@ namespace RookieStation.Finishes
|
||||
return Result.Failed;
|
||||
}
|
||||
|
||||
WpfFloorFinishes floorCovering = CommonUtils.GenerateWindow<WpfFloorFinishes>();
|
||||
WpfFloorFinishes floorFinishes = CommonUtils.GenerateWindow<WpfFloorFinishes>();
|
||||
|
||||
double length, width, gap, thickness;
|
||||
|
||||
if (floorCovering.DialogResult == true)
|
||||
bool IsByRoom = false;
|
||||
if (floorFinishes.DialogResult == true)
|
||||
{
|
||||
length = floorCovering.PavementLength;
|
||||
width = floorCovering.PavementWidth;
|
||||
gap = floorCovering.PavementGap;
|
||||
thickness = floorCovering.PavementThickness;
|
||||
length = floorFinishes.PavementLength;
|
||||
width = floorFinishes.PavementWidth;
|
||||
gap = floorFinishes.PavementGap;
|
||||
thickness = floorFinishes.PavementThickness;
|
||||
IsByRoom = floorFinishes.IsByRoom;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Result.Cancelled;
|
||||
}
|
||||
if (IsByRoom)
|
||||
{
|
||||
CreateCurtainSystemByRoom(uidoc, length, width, gap, thickness);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateCurtainSystemByFace(uidoc, length, width, gap, thickness);
|
||||
}
|
||||
|
||||
CreateCurtainSystemByFace(uidoc, doc, length, width, gap, thickness);
|
||||
//CreateCurtainSystemByRoom(uidoc, length, width, gap, thickness);
|
||||
return Result.Succeeded;
|
||||
//ModelCurveArray mca = new ModelCurveArray();
|
||||
@@ -64,8 +72,9 @@ namespace RookieStation.Finishes
|
||||
//});
|
||||
}
|
||||
|
||||
private static void CreateCurtainSystemByFace(UIDocument uidoc, Document doc, double length, double width, double gap, double thickness)
|
||||
private static void CreateCurtainSystemByFace(UIDocument uidoc, double length, double width, double gap, double thickness)
|
||||
{
|
||||
Document doc = uidoc.Document;
|
||||
Reference faceReference = uidoc.Selection.PickObject(ObjectType.Face, "请选择铺贴面");
|
||||
Element element = doc.GetElement(faceReference);
|
||||
Face face = element.GetGeometryObjectFromReference(faceReference) as Face;
|
||||
@@ -233,16 +242,14 @@ namespace RookieStation.Finishes
|
||||
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.SPACING_LENGTH_1).Set((length + gap) / 304.8);
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.SPACING_LENGTH_2).Set((width + gap) / 304.8);
|
||||
try
|
||||
{
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_PANEL).Set(panelType.Id);
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_INTERIOR_GRID1).Set(mullionType.Id);
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_INTERIOR_GRID2).Set(mullionType.Id);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_PANEL).Set(panelType.Id);
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_INTERIOR_GRID1).Set(mullionType.Id);
|
||||
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_INTERIOR_GRID2).Set(mullionType.Id);
|
||||
//curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER1_GRID1).Set(mullionType.Id);
|
||||
//curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER1_GRID2).Set(mullionType.Id);
|
||||
//curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER2_GRID1).Set(mullionType.Id);
|
||||
//curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER2_GRID2).Set(mullionType.Id);
|
||||
}, "设置参数");
|
||||
return curtainSystemType;
|
||||
}
|
||||
|
||||
10
RookieStation/Properties/Resources.Designer.cs
generated
10
RookieStation/Properties/Resources.Designer.cs
generated
@@ -120,6 +120,16 @@ namespace RookieStation.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap LogoExtrusion {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("LogoExtrusion", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||
/// </summary>
|
||||
|
||||
@@ -136,6 +136,9 @@
|
||||
<data name="Lamp" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\lamp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="LogoExtrusion" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\logoextrusion.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Reception" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\resources\reception.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
||||
BIN
RookieStation/Resources/LogoExtrusion.png
Normal file
BIN
RookieStation/Resources/LogoExtrusion.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -329,6 +329,7 @@
|
||||
<None Include="Resources\Shipping.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\LogoExtrusion.png" />
|
||||
<Content Include="Resources\WallFinishes.png" />
|
||||
<Content Include="Resources\YTX.ico" />
|
||||
<None Include="Resources\WorkSchedule.png" />
|
||||
|
||||
@@ -73,6 +73,14 @@ namespace RookieStation
|
||||
};
|
||||
var receptionBtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD);
|
||||
receptionBtn.AvailabilityClassName = ViewPlanCmdEnabled;
|
||||
|
||||
PushButtonData logoExtrusionPBD = new PushButtonData("标识挤出", "标识挤出", AddInPath, typeof(CmdLogoExtrusion).FullName)
|
||||
{
|
||||
LargeImage = ConvertFromBitmap(Properties.Resources.LogoExtrusion),
|
||||
Image = ConvertFromBitmap(Properties.Resources.LogoExtrusion)
|
||||
};
|
||||
receptionAreaPanel.AddItem(logoExtrusionPBD);
|
||||
|
||||
//出入口布置
|
||||
RibbonPanel packAreaPanel = application.CreateRibbonPanel(TabName, EntranceAndExitGatePanelName);
|
||||
PushButtonData entrancegateLayoutPBD = new PushButtonData("入口布置", "入口闸机", AddInPath, typeof(CmdPlaceEntranceGate).FullName)
|
||||
|
||||
@@ -79,11 +79,16 @@
|
||||
TextAlignment="Center" />
|
||||
</GroupBox>
|
||||
<Button
|
||||
x:Name="btnConfirm"
|
||||
x:Name="btnByRoom"
|
||||
Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Click="btnConfirm_Click"
|
||||
Content="铺设" />
|
||||
Content="房间铺设" />
|
||||
<Button
|
||||
x:Name="btnByFace"
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
Click="btnConfirm_Click"
|
||||
Content="按面铺设" />
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -20,6 +20,7 @@ namespace RookieStation
|
||||
/// </summary>
|
||||
public partial class WpfFloorFinishes
|
||||
{
|
||||
public bool IsByRoom { get; set; }
|
||||
public double PavementLength { get; set; }
|
||||
|
||||
public double PavementWidth { get; set; }
|
||||
@@ -41,6 +42,7 @@ namespace RookieStation
|
||||
var b = double.TryParse(tbPavementWidth.Text, out width);
|
||||
var c = double.TryParse(tbPavementGap.Text, out gap);
|
||||
var d = double.TryParse(tbPavementGap.Text, out thickness);
|
||||
Button btn = sender as Button;
|
||||
if (a && b && c && d)
|
||||
{
|
||||
PavementLength = length;
|
||||
@@ -48,6 +50,14 @@ namespace RookieStation
|
||||
PavementGap = gap;
|
||||
PavementThickness = thickness;
|
||||
DialogResult = true;
|
||||
if (btn.Name == "btnByRoom")
|
||||
{
|
||||
IsByRoom = true;
|
||||
}
|
||||
else if (btn.Name == "btnByFace")
|
||||
{
|
||||
IsByRoom = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user