Compare commits
4 Commits
b693d8a092
...
60bd4ff645
| Author | SHA1 | Date | |
|---|---|---|---|
| 60bd4ff645 | |||
| e9a7b51d24 | |||
| 016e32c2e3 | |||
| 16c9d97e22 |
@@ -94,10 +94,15 @@
|
|||||||
<Compile Include="DrawingInfo.cs" />
|
<Compile Include="DrawingInfo.cs" />
|
||||||
<Compile Include="BomToExcel.cs" />
|
<Compile Include="BomToExcel.cs" />
|
||||||
<Compile Include="Extensions.cs" />
|
<Compile Include="Extensions.cs" />
|
||||||
<Compile Include="ItemExtractor.cs" />
|
<Compile Include="ItemExtractors\AssemblyItemExtractor.cs" />
|
||||||
|
<Compile Include="ItemExtractors\BomColumnIndices.cs" />
|
||||||
|
<Compile Include="ItemExtractors\BomItemExtractor.cs" />
|
||||||
|
<Compile Include="ItemExtractors\ItemExtractor.cs" />
|
||||||
<Compile Include="Forms\ViewFlipDeciderComboboxItem.cs" />
|
<Compile Include="Forms\ViewFlipDeciderComboboxItem.cs" />
|
||||||
<Compile Include="Item.cs" />
|
<Compile Include="Item.cs" />
|
||||||
<Compile Include="IViewFlipDecider.cs" />
|
<Compile Include="ViewFlipDeciders\AskViewFlipDecider.cs" />
|
||||||
|
<Compile Include="ViewFlipDeciders\AutoViewFlipDecider.cs" />
|
||||||
|
<Compile Include="ViewFlipDeciders\IViewFlipDecider.cs" />
|
||||||
<Compile Include="Helper.cs" />
|
<Compile Include="Helper.cs" />
|
||||||
<Compile Include="Forms\MainForm.cs">
|
<Compile Include="Forms\MainForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
@@ -109,6 +114,7 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SolidWorksExtensions.cs" />
|
<Compile Include="SolidWorksExtensions.cs" />
|
||||||
<Compile Include="Units.cs" />
|
<Compile Include="Units.cs" />
|
||||||
|
<Compile Include="ViewFlipDeciders\PreferUpViewFlipDecider.cs" />
|
||||||
<Compile Include="ViewHelper.cs" />
|
<Compile Include="ViewHelper.cs" />
|
||||||
<EmbeddedResource Include="Forms\MainForm.resx">
|
<EmbeddedResource Include="Forms\MainForm.resx">
|
||||||
<DependentUpon>MainForm.cs</DependentUpon>
|
<DependentUpon>MainForm.cs</DependentUpon>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using OfficeOpenXml;
|
using ExportDXF.ItemExtractors;
|
||||||
|
using ExportDXF.ViewFlipDeciders;
|
||||||
|
using OfficeOpenXml;
|
||||||
using SolidWorks.Interop.sldworks;
|
using SolidWorks.Interop.sldworks;
|
||||||
using SolidWorks.Interop.swconst;
|
using SolidWorks.Interop.swconst;
|
||||||
using System;
|
using System;
|
||||||
@@ -504,12 +506,12 @@ namespace ExportDXF.Forms
|
|||||||
var drawingModel = templateDrawing as ModelDoc2;
|
var drawingModel = templateDrawing as ModelDoc2;
|
||||||
drawingModel.ViewZoomtofit2();
|
drawingModel.ViewZoomtofit2();
|
||||||
|
|
||||||
if (HasSupressedBends(view))
|
if (ViewHelper.HasSupressedBends(view))
|
||||||
{
|
{
|
||||||
Print("A bend is suppressed, please check flat pattern!", Color.Red);
|
Print("A bend is suppressed, please check flat pattern!", Color.Red);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HideModelSketches(view))
|
if (ViewHelper.HideModelSketches(view))
|
||||||
{
|
{
|
||||||
// delete the current view that has sketches shown
|
// delete the current view that has sketches shown
|
||||||
drawingModel.SelectByName(0, view.Name);
|
drawingModel.SelectByName(0, view.Name);
|
||||||
@@ -545,59 +547,6 @@ namespace ExportDXF.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool HasSupressedBends(IView view)
|
|
||||||
{
|
|
||||||
var model = view.ReferencedDocument;
|
|
||||||
var refConfig = view.ReferencedConfiguration;
|
|
||||||
model.ShowConfiguration(refConfig);
|
|
||||||
|
|
||||||
var flatPattern = model.GetFeatureByTypeName("FlatPattern");
|
|
||||||
|
|
||||||
if (flatPattern.IsSuppressed())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var bends = flatPattern.GetAllSubFeaturesByTypeName("UiBend");
|
|
||||||
|
|
||||||
foreach (var bend in bends)
|
|
||||||
{
|
|
||||||
var isSuppressed = bend.IsSuppressed();
|
|
||||||
if (isSuppressed)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool HideModelSketches(IView view)
|
|
||||||
{
|
|
||||||
var model = view.ReferencedDocument;
|
|
||||||
var activeConfig = ((Configuration)model.GetActiveConfiguration()).Name;
|
|
||||||
|
|
||||||
var modelChanged = false;
|
|
||||||
var refConfig = view.ReferencedConfiguration;
|
|
||||||
model.ShowConfiguration(refConfig);
|
|
||||||
|
|
||||||
var sketches = model.GetAllFeaturesByTypeName("ProfileFeature");
|
|
||||||
|
|
||||||
foreach (var sketch in sketches)
|
|
||||||
{
|
|
||||||
var visible = (swVisibilityState_e)sketch.Visible;
|
|
||||||
|
|
||||||
if (visible == swVisibilityState_e.swVisibilityStateShown)
|
|
||||||
{
|
|
||||||
sketch.Select2(true, -1);
|
|
||||||
model.BlankSketch();
|
|
||||||
modelChanged = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
model.ShowConfiguration(activeConfig);
|
|
||||||
|
|
||||||
return modelChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string UserSelectFolder()
|
private string UserSelectFolder()
|
||||||
{
|
{
|
||||||
string path = null;
|
string path = null;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
namespace ExportDXF.Forms
|
using ExportDXF.ViewFlipDeciders;
|
||||||
|
|
||||||
|
namespace ExportDXF.Forms
|
||||||
{
|
{
|
||||||
public class ViewFlipDeciderComboboxItem
|
public class ViewFlipDeciderComboboxItem
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ExportDXF
|
|
||||||
{
|
|
||||||
public interface IViewFlipDecider
|
|
||||||
{
|
|
||||||
bool ShouldFlip(SolidWorks.Interop.sldworks.View view);
|
|
||||||
|
|
||||||
string Name { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AutoViewFlipDecider : IViewFlipDecider
|
|
||||||
{
|
|
||||||
public string Name => "Automatic";
|
|
||||||
|
|
||||||
public bool ShouldFlip(SolidWorks.Interop.sldworks.View view)
|
|
||||||
{
|
|
||||||
var orientation = ViewHelper.GetOrientation(view);
|
|
||||||
var bounds = ViewHelper.GetBounds(view);
|
|
||||||
var bends = ViewHelper.GetBends(view);
|
|
||||||
|
|
||||||
var up = bends.Where(b => b.Direction == BendDirection.Up).ToList();
|
|
||||||
var down = bends.Where(b => b.Direction == BendDirection.Down).ToList();
|
|
||||||
|
|
||||||
if (down.Count == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (up.Count == 0)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
var bend = ViewHelper.GetBendClosestToBounds(bounds, bends);
|
|
||||||
|
|
||||||
return bend.Direction == BendDirection.Down;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AskViewFlipDecider : IViewFlipDecider
|
|
||||||
{
|
|
||||||
public string Name => "Ask to flip";
|
|
||||||
|
|
||||||
public bool ShouldFlip(SolidWorks.Interop.sldworks.View view)
|
|
||||||
{
|
|
||||||
var bends = ViewHelper.GetBends(view);
|
|
||||||
|
|
||||||
if (bends.Count == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return Name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PreferUpViewFlipDecider : IViewFlipDecider
|
|
||||||
{
|
|
||||||
public string Name => "Prefer up bends, ask if up/down";
|
|
||||||
|
|
||||||
public bool ShouldFlip(SolidWorks.Interop.sldworks.View view)
|
|
||||||
{
|
|
||||||
var bends = ViewHelper.GetBends(view);
|
|
||||||
var up = bends.Where(b => b.Direction == BendDirection.Up).ToList();
|
|
||||||
var down = bends.Where(b => b.Direction == BendDirection.Down).ToList();
|
|
||||||
|
|
||||||
if (up.Count > 0 && down.Count > 0)
|
|
||||||
{
|
|
||||||
return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return down.Count > 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
64
ExportDXF/ItemExtractors/AssemblyItemExtractor.cs
Normal file
64
ExportDXF/ItemExtractors/AssemblyItemExtractor.cs
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
using SolidWorks.Interop.sldworks;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace ExportDXF.ItemExtractors
|
||||||
|
{
|
||||||
|
public class AssemblyItemExtractor : ItemExtractor
|
||||||
|
{
|
||||||
|
private AssemblyDoc assembly;
|
||||||
|
|
||||||
|
public AssemblyItemExtractor(AssemblyDoc assembly)
|
||||||
|
{
|
||||||
|
this.assembly = assembly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool TopLevelOnly { get; set; }
|
||||||
|
|
||||||
|
private string GetComponentName(Component2 component)
|
||||||
|
{
|
||||||
|
var filepath = component.GetTitle();
|
||||||
|
var filename = Path.GetFileNameWithoutExtension(filepath);
|
||||||
|
var isDefaultConfig = component.ReferencedConfiguration.ToLower() == "default";
|
||||||
|
|
||||||
|
return isDefaultConfig ? filename : $"{filename} [{component.ReferencedConfiguration}]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Item> GetItems()
|
||||||
|
{
|
||||||
|
var list = new List<Item>();
|
||||||
|
|
||||||
|
assembly.ResolveAllLightWeightComponents(false);
|
||||||
|
|
||||||
|
var assemblyComponents = ((Array)assembly.GetComponents(TopLevelOnly))
|
||||||
|
.Cast<Component2>()
|
||||||
|
.Where(c => !c.IsHidden(true));
|
||||||
|
|
||||||
|
var componentGroups = assemblyComponents
|
||||||
|
.GroupBy(c => c.GetTitle() + c.ReferencedConfiguration);
|
||||||
|
|
||||||
|
foreach (var group in componentGroups)
|
||||||
|
{
|
||||||
|
var component = group.First();
|
||||||
|
var model = component.GetModelDoc2() as ModelDoc2;
|
||||||
|
|
||||||
|
if (model == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var name = GetComponentName(component);
|
||||||
|
|
||||||
|
list.Add(new Item
|
||||||
|
{
|
||||||
|
PartName = name,
|
||||||
|
Quantity = group.Count(),
|
||||||
|
Component = component,
|
||||||
|
Configuration = component.ReferencedConfiguration
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
13
ExportDXF/ItemExtractors/BomColumnIndices.cs
Normal file
13
ExportDXF/ItemExtractors/BomColumnIndices.cs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
namespace ExportDXF.ItemExtractors
|
||||||
|
{
|
||||||
|
public class BomColumnIndices
|
||||||
|
{
|
||||||
|
public int ItemNumber { get; set; } = -1;
|
||||||
|
|
||||||
|
public int Quantity { get; set; } = -1;
|
||||||
|
|
||||||
|
public int Description { get; set; } = -1;
|
||||||
|
|
||||||
|
public int PartNumber { get; set; } = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,16 +2,10 @@
|
|||||||
using SolidWorks.Interop.swconst;
|
using SolidWorks.Interop.swconst;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace ExportDXF
|
namespace ExportDXF.ItemExtractors
|
||||||
{
|
{
|
||||||
public interface ItemExtractor
|
|
||||||
{
|
|
||||||
List<Item> GetItems();
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BomItemExtractor : ItemExtractor
|
public class BomItemExtractor : ItemExtractor
|
||||||
{
|
{
|
||||||
private BomTableAnnotation bom;
|
private BomTableAnnotation bom;
|
||||||
@@ -142,71 +136,4 @@ namespace ExportDXF
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class AssemblyItemExtractor : ItemExtractor
|
|
||||||
{
|
|
||||||
private AssemblyDoc assembly;
|
|
||||||
|
|
||||||
public AssemblyItemExtractor(AssemblyDoc assembly)
|
|
||||||
{
|
|
||||||
this.assembly = assembly;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool TopLevelOnly { get; set; }
|
|
||||||
|
|
||||||
private string GetComponentName(Component2 component)
|
|
||||||
{
|
|
||||||
var filepath = component.GetTitle();
|
|
||||||
var filename = Path.GetFileNameWithoutExtension(filepath);
|
|
||||||
var isDefaultConfig = component.ReferencedConfiguration.ToLower() == "default";
|
|
||||||
|
|
||||||
return isDefaultConfig ? filename : $"{filename} [{component.ReferencedConfiguration}]";
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Item> GetItems()
|
|
||||||
{
|
|
||||||
var list = new List<Item>();
|
|
||||||
|
|
||||||
assembly.ResolveAllLightWeightComponents(false);
|
|
||||||
|
|
||||||
var assemblyComponents = ((Array)assembly.GetComponents(TopLevelOnly))
|
|
||||||
.Cast<Component2>()
|
|
||||||
.Where(c => !c.IsHidden(true));
|
|
||||||
|
|
||||||
var componentGroups = assemblyComponents
|
|
||||||
.GroupBy(c => c.GetTitle() + c.ReferencedConfiguration);
|
|
||||||
|
|
||||||
foreach (var group in componentGroups)
|
|
||||||
{
|
|
||||||
var component = group.First();
|
|
||||||
var model = component.GetModelDoc2() as ModelDoc2;
|
|
||||||
|
|
||||||
if (model == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
var name = GetComponentName(component);
|
|
||||||
|
|
||||||
list.Add(new Item
|
|
||||||
{
|
|
||||||
PartName = name,
|
|
||||||
Quantity = group.Count(),
|
|
||||||
Component = component,
|
|
||||||
Configuration = component.ReferencedConfiguration
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class BomColumnIndices
|
|
||||||
{
|
|
||||||
public int ItemNumber { get; set; } = -1;
|
|
||||||
|
|
||||||
public int Quantity { get; set; } = -1;
|
|
||||||
|
|
||||||
public int Description { get; set; } = -1;
|
|
||||||
|
|
||||||
public int PartNumber { get; set; } = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
9
ExportDXF/ItemExtractors/ItemExtractor.cs
Normal file
9
ExportDXF/ItemExtractors/ItemExtractor.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace ExportDXF.ItemExtractors
|
||||||
|
{
|
||||||
|
public interface ItemExtractor
|
||||||
|
{
|
||||||
|
List<Item> GetItems();
|
||||||
|
}
|
||||||
|
}
|
||||||
24
ExportDXF/ViewFlipDeciders/AskViewFlipDecider.cs
Normal file
24
ExportDXF/ViewFlipDeciders/AskViewFlipDecider.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ExportDXF.ViewFlipDeciders
|
||||||
|
{
|
||||||
|
public class AskViewFlipDecider : IViewFlipDecider
|
||||||
|
{
|
||||||
|
public string Name => "Ask to flip";
|
||||||
|
|
||||||
|
public bool ShouldFlip(SolidWorks.Interop.sldworks.View view)
|
||||||
|
{
|
||||||
|
var bends = ViewHelper.GetBends(view);
|
||||||
|
|
||||||
|
if (bends.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return Name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
ExportDXF/ViewFlipDeciders/AutoViewFlipDecider.cs
Normal file
29
ExportDXF/ViewFlipDeciders/AutoViewFlipDecider.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace ExportDXF.ViewFlipDeciders
|
||||||
|
{
|
||||||
|
public class AutoViewFlipDecider : IViewFlipDecider
|
||||||
|
{
|
||||||
|
public string Name => "Automatic";
|
||||||
|
|
||||||
|
public bool ShouldFlip(SolidWorks.Interop.sldworks.View view)
|
||||||
|
{
|
||||||
|
var orientation = ViewHelper.GetOrientation(view);
|
||||||
|
var bounds = ViewHelper.GetBounds(view);
|
||||||
|
var bends = ViewHelper.GetBends(view);
|
||||||
|
|
||||||
|
var up = bends.Where(b => b.Direction == BendDirection.Up).ToList();
|
||||||
|
var down = bends.Where(b => b.Direction == BendDirection.Down).ToList();
|
||||||
|
|
||||||
|
if (down.Count == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (up.Count == 0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
var bend = ViewHelper.GetBendClosestToBounds(bounds, bends);
|
||||||
|
|
||||||
|
return bend.Direction == BendDirection.Down;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
ExportDXF/ViewFlipDeciders/IViewFlipDecider.cs
Normal file
9
ExportDXF/ViewFlipDeciders/IViewFlipDecider.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
namespace ExportDXF.ViewFlipDeciders
|
||||||
|
{
|
||||||
|
public interface IViewFlipDecider
|
||||||
|
{
|
||||||
|
bool ShouldFlip(SolidWorks.Interop.sldworks.View view);
|
||||||
|
|
||||||
|
string Name { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
26
ExportDXF/ViewFlipDeciders/PreferUpViewFlipDecider.cs
Normal file
26
ExportDXF/ViewFlipDeciders/PreferUpViewFlipDecider.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ExportDXF.ViewFlipDeciders
|
||||||
|
{
|
||||||
|
public class PreferUpViewFlipDecider : IViewFlipDecider
|
||||||
|
{
|
||||||
|
public string Name => "Prefer up bends, ask if up/down";
|
||||||
|
|
||||||
|
public bool ShouldFlip(SolidWorks.Interop.sldworks.View view)
|
||||||
|
{
|
||||||
|
var bends = ViewHelper.GetBends(view);
|
||||||
|
var up = bends.Where(b => b.Direction == BendDirection.Up).ToList();
|
||||||
|
var down = bends.Where(b => b.Direction == BendDirection.Down).ToList();
|
||||||
|
|
||||||
|
if (up.Count > 0 && down.Count > 0)
|
||||||
|
{
|
||||||
|
return MessageBox.Show("Flip view?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return down.Count > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using SolidWorks.Interop.sldworks;
|
using SolidWorks.Interop.sldworks;
|
||||||
|
using SolidWorks.Interop.swconst;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -269,5 +270,58 @@ namespace ExportDXF
|
|||||||
{
|
{
|
||||||
return Math.Round(angleInRadians * 180.0 / Math.PI, 8);
|
return Math.Round(angleInRadians * 180.0 / Math.PI, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool HideModelSketches(IView view)
|
||||||
|
{
|
||||||
|
var model = view.ReferencedDocument;
|
||||||
|
var activeConfig = ((Configuration)model.GetActiveConfiguration()).Name;
|
||||||
|
|
||||||
|
var modelChanged = false;
|
||||||
|
var refConfig = view.ReferencedConfiguration;
|
||||||
|
model.ShowConfiguration(refConfig);
|
||||||
|
|
||||||
|
var sketches = model.GetAllFeaturesByTypeName("ProfileFeature");
|
||||||
|
|
||||||
|
foreach (var sketch in sketches)
|
||||||
|
{
|
||||||
|
var visible = (swVisibilityState_e)sketch.Visible;
|
||||||
|
|
||||||
|
if (visible == swVisibilityState_e.swVisibilityStateShown)
|
||||||
|
{
|
||||||
|
sketch.Select2(true, -1);
|
||||||
|
model.BlankSketch();
|
||||||
|
modelChanged = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.ShowConfiguration(activeConfig);
|
||||||
|
|
||||||
|
return modelChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool HasSupressedBends(IView view)
|
||||||
|
{
|
||||||
|
var model = view.ReferencedDocument;
|
||||||
|
var refConfig = view.ReferencedConfiguration;
|
||||||
|
model.ShowConfiguration(refConfig);
|
||||||
|
|
||||||
|
var flatPattern = model.GetFeatureByTypeName("FlatPattern");
|
||||||
|
|
||||||
|
if (flatPattern.IsSuppressed())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var bends = flatPattern.GetAllSubFeaturesByTypeName("UiBend");
|
||||||
|
|
||||||
|
foreach (var bend in bends)
|
||||||
|
{
|
||||||
|
var isSuppressed = bend.IsSuppressed();
|
||||||
|
if (isSuppressed)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user