LOGO挤出

This commit is contained in:
GG Z
2021-06-23 12:51:54 +08:00
parent 49f7cbddc0
commit 52d30a7ad9
9 changed files with 180 additions and 84 deletions

View File

@@ -20,11 +20,18 @@ namespace RookieStation
UIDocument uidoc = uiapp.ActiveUIDocument; UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;
Document doc = uidoc.Document; 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>(); List<Curve> curves = new List<Curve>();
ImportInstance importInstance = null;
var geometryElement = instances.First().get_Geometry(new Options()); string familyfilename = string.Empty;
//var geometryElement = instances.First().get_Geometry(new Options());
try
{
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 geomObj in geometryElement)
{ {
GeometryInstance geometryInstance = geomObj as GeometryInstance; GeometryInstance geometryInstance = geomObj as GeometryInstance;
@@ -33,14 +40,36 @@ namespace RookieStation
foreach (var instObj in geometryInstance.GetSymbolGeometry()) foreach (var instObj in geometryInstance.GetSymbolGeometry())
{ {
Curve curve = instObj as Curve; Curve curve = instObj as Curve;
if (curve == null) 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; continue;
} }
curves.Add(curve);
} }
} }
} }
}
}
}
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
{
return Result.Cancelled;
}
//doc.Invoke(ts => //doc.Invoke(ts =>
//{ //{
// foreach (var curve in curves) // foreach (var curve in curves)
@@ -51,60 +80,80 @@ namespace RookieStation
//}); //});
CurveArrArray arrArray = new CurveArrArray(); CurveArrArray arrArray = new CurveArrArray();
CurveArray array = new CurveArray(); CurveArray array = new CurveArray();
if (curves.Count == 0)
{
return Result.Failed;
}
SearchCurveConnected(curves, curves.FirstOrDefault(), array, arrArray); SearchCurveConnected(curves, curves.FirstOrDefault(), array, arrArray);
//do string rftPath = app.FamilyTemplatePath + "\\概念体量\\公制体量.rft";
//{
// 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--) Document faDoc = app.NewFamilyDocument(rftPath);
// {
// Curve tempCurve = curves[j];
// if (tempCurve.GetEndPoint(0).IsAlmostEqualTo(tempEndXyz)) doc.InvokeGroup(tg =>
{
faDoc.Invoke(ts =>
{
SketchPlane plane = SketchPlane.Create(faDoc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero));
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)
//{ //{
// baseCurve = tempCurve; // referenceArray.Append(c.GeometryCurve.Reference);
// tempEndXyz = tempCurve.GetEndPoint(1);
// array.Append(tempCurve);
// curves.Remove(tempCurve);
// continue;
//} //}
// else if (tempCurve.GetEndPoint(1).IsAlmostEqualTo(tempEndXyz)) }
//foreach (CurveArray arr in arrArray)
//{ //{
// baseCurve = tempCurve; // var ml = doc.FamilyCreate.NewModelCurveArray(arr, plane);
// tempEndXyz = tempCurve.GetEndPoint(0); // //doc.FamilyCreate.NewExtrusion(true, arrArray, plane, 5.0 / 304.8);
// array.Append(tempCurve);
// curves.Remove(tempCurve);
// continue;
//} //}
// } });
// arrArray.Append(array); Family fa = faDoc.LoadFamily(doc);
//} while (curves.Count > 0);
faDoc.Close(false);
doc.Invoke(ts => doc.Invoke(ts =>
{ {
SketchPlane plane = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero)); if (fa != null)
foreach (CurveArray arr in arrArray)
{ {
var ml = doc.FamilyCreate.NewModelCurveArray(arr, plane); 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);
} }
//foreach (CurveArray arr in arrArray)
//{
// doc.FamilyCreate.NewExtrusion(true, arrArray, plane, 5.0 / 304.8);
// //var ml = doc.FamilyCreate.NewModelCurveArray(arr, plane);
//}
}); });
});
return Result.Succeeded; return Result.Succeeded;
} }
/// <summary> /// <summary>
/// 找到所有连接在一起的线圈并分好组 /// 递归找到所有连接在一起的线圈并分好组
/// </summary> /// </summary>
/// <param name="curves">所有线</param> /// <param name="curves">所有线</param>
/// <param name="initcurve">用于查找与其连接的初始线</param> /// <param name="initcurve">用于查找与其连接的初始线</param>
@@ -116,17 +165,21 @@ namespace RookieStation
{ {
Curve tempCurve = curves[i]; Curve tempCurve = curves[i];
var baseEndXyz = initcurve.GetEndPoint(0); var baseEndXyz = initcurve.GetEndPoint(0);
//把初始的第一个添加进集合
if (curveArrArray.Size == 0)
{
curveArrArray.Append(initCurveArray);
}
if (tempCurve.GetEndPoint(0).IsAlmostEqualTo(baseEndXyz) || tempCurve.GetEndPoint(1).IsAlmostEqualTo(baseEndXyz)) if (tempCurve.GetEndPoint(0).IsAlmostEqualTo(baseEndXyz) || tempCurve.GetEndPoint(1).IsAlmostEqualTo(baseEndXyz))
{ {
initCurveArray.Append(tempCurve); initCurveArray.Append(tempCurve);
curves.Remove(tempCurve); curves.Remove(tempCurve);
SearchCurveConnected(curves, tempCurve, initCurveArray, curveArrArray); 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(); //array.Clear();
initCurveArray = new CurveArray(); initCurveArray = new CurveArray();
SearchCurveConnected(curves, curves.FirstOrDefault(), initCurveArray, curveArrArray); SearchCurveConnected(curves, curves.FirstOrDefault(), initCurveArray, curveArrArray);
@@ -135,7 +188,6 @@ namespace RookieStation
{ {
curveArrArray.Append(initCurveArray); curveArrArray.Append(initCurveArray);
} }
return;
} }
} }
} }

View File

@@ -28,23 +28,31 @@ namespace RookieStation.Finishes
return Result.Failed; return Result.Failed;
} }
WpfFloorFinishes floorCovering = CommonUtils.GenerateWindow<WpfFloorFinishes>(); WpfFloorFinishes floorFinishes = CommonUtils.GenerateWindow<WpfFloorFinishes>();
double length, width, gap, thickness; double length, width, gap, thickness;
bool IsByRoom = false;
if (floorCovering.DialogResult == true) if (floorFinishes.DialogResult == true)
{ {
length = floorCovering.PavementLength; length = floorFinishes.PavementLength;
width = floorCovering.PavementWidth; width = floorFinishes.PavementWidth;
gap = floorCovering.PavementGap; gap = floorFinishes.PavementGap;
thickness = floorCovering.PavementThickness; thickness = floorFinishes.PavementThickness;
IsByRoom = floorFinishes.IsByRoom;
} }
else else
{ {
return Result.Cancelled; 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); //CreateCurtainSystemByRoom(uidoc, length, width, gap, thickness);
return Result.Succeeded; return Result.Succeeded;
//ModelCurveArray mca = new ModelCurveArray(); //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, "请选择铺贴面"); Reference faceReference = uidoc.Selection.PickObject(ObjectType.Face, "请选择铺贴面");
Element element = doc.GetElement(faceReference); Element element = doc.GetElement(faceReference);
Face face = element.GetGeometryObjectFromReference(faceReference) as Face; 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_1).Set((length + gap) / 304.8);
curtainSystemType.get_Parameter(BuiltInParameter.SPACING_LENGTH_2).Set((width + 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_PANEL).Set(panelType.Id);
curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_INTERIOR_GRID1).Set(mullionType.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_INTERIOR_GRID2).Set(mullionType.Id);
} //curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER1_GRID1).Set(mullionType.Id);
catch (Exception) //curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER1_GRID2).Set(mullionType.Id);
{ //curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER2_GRID1).Set(mullionType.Id);
throw; //curtainSystemType.get_Parameter(BuiltInParameter.AUTO_MULLION_BORDER2_GRID2).Set(mullionType.Id);
}
}, "设置参数"); }, "设置参数");
return curtainSystemType; return curtainSystemType;
} }

View File

@@ -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> /// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。 /// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary> /// </summary>

View File

@@ -136,6 +136,9 @@
<data name="Lamp" type="System.Resources.ResXFileRef, System.Windows.Forms"> <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> <value>..\resources\lamp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </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"> <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> <value>..\resources\reception.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -329,6 +329,7 @@
<None Include="Resources\Shipping.png" /> <None Include="Resources\Shipping.png" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Resources\LogoExtrusion.png" />
<Content Include="Resources\WallFinishes.png" /> <Content Include="Resources\WallFinishes.png" />
<Content Include="Resources\YTX.ico" /> <Content Include="Resources\YTX.ico" />
<None Include="Resources\WorkSchedule.png" /> <None Include="Resources\WorkSchedule.png" />

View File

@@ -73,6 +73,14 @@ namespace RookieStation
}; };
var receptionBtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD); var receptionBtn = (PushButton)receptionAreaPanel.AddItem(receptionLayoutPBD);
receptionBtn.AvailabilityClassName = ViewPlanCmdEnabled; 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); RibbonPanel packAreaPanel = application.CreateRibbonPanel(TabName, EntranceAndExitGatePanelName);
PushButtonData entrancegateLayoutPBD = new PushButtonData("入口布置", "入口闸机", AddInPath, typeof(CmdPlaceEntranceGate).FullName) PushButtonData entrancegateLayoutPBD = new PushButtonData("入口布置", "入口闸机", AddInPath, typeof(CmdPlaceEntranceGate).FullName)

View File

@@ -79,11 +79,16 @@
TextAlignment="Center" /> TextAlignment="Center" />
</GroupBox> </GroupBox>
<Button <Button
x:Name="btnConfirm" x:Name="btnByRoom"
Grid.Row="2" Grid.Row="2"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="2"
Click="btnConfirm_Click" Click="btnConfirm_Click"
Content="铺设" /> Content="房间铺设" />
<Button
x:Name="btnByFace"
Grid.Row="2"
Grid.Column="1"
Click="btnConfirm_Click"
Content="按面铺设" />
</Grid> </Grid>
</Window> </Window>

View File

@@ -20,6 +20,7 @@ namespace RookieStation
/// </summary> /// </summary>
public partial class WpfFloorFinishes public partial class WpfFloorFinishes
{ {
public bool IsByRoom { get; set; }
public double PavementLength { get; set; } public double PavementLength { get; set; }
public double PavementWidth { get; set; } public double PavementWidth { get; set; }
@@ -41,6 +42,7 @@ namespace RookieStation
var b = double.TryParse(tbPavementWidth.Text, out width); var b = double.TryParse(tbPavementWidth.Text, out width);
var c = double.TryParse(tbPavementGap.Text, out gap); var c = double.TryParse(tbPavementGap.Text, out gap);
var d = double.TryParse(tbPavementGap.Text, out thickness); var d = double.TryParse(tbPavementGap.Text, out thickness);
Button btn = sender as Button;
if (a && b && c && d) if (a && b && c && d)
{ {
PavementLength = length; PavementLength = length;
@@ -48,6 +50,14 @@ namespace RookieStation
PavementGap = gap; PavementGap = gap;
PavementThickness = thickness; PavementThickness = thickness;
DialogResult = true; DialogResult = true;
if (btn.Name == "btnByRoom")
{
IsByRoom = true;
}
else if (btn.Name == "btnByFace")
{
IsByRoom = false;
}
} }
else else
{ {