Compare commits
2 Commits
97f45b2fcc
...
c1aaaf07ee
| Author | SHA1 | Date | |
|---|---|---|---|
| c1aaaf07ee | |||
| 63b96e1451 |
@@ -548,9 +548,12 @@ namespace ExportDXF.Forms
|
|||||||
var drawingModel = templateDrawing as ModelDoc2;
|
var drawingModel = templateDrawing as ModelDoc2;
|
||||||
drawingModel.ViewZoomtofit2();
|
drawingModel.ViewZoomtofit2();
|
||||||
|
|
||||||
|
var flatPatternModel = ViewHelper.GetModelFromView(view);
|
||||||
|
Helper.SetFlatPatternSuppressionState(flatPatternModel, swComponentSuppressionState_e.swComponentFullyResolved);
|
||||||
|
|
||||||
if (ViewHelper.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 (ViewHelper.HideModelSketches(view))
|
if (ViewHelper.HideModelSketches(view))
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using SolidWorks.Interop.sldworks;
|
using SolidWorks.Interop.sldworks;
|
||||||
|
using SolidWorks.Interop.swconst;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace ExportDXF
|
namespace ExportDXF
|
||||||
{
|
{
|
||||||
@@ -31,5 +33,29 @@ namespace ExportDXF
|
|||||||
|
|
||||||
var ret = flatPattern.ModifyDefinition(flatPatternFeatureData, model, null);
|
var ret = flatPattern.ModifyDefinition(flatPatternFeatureData, model, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool SetFlatPatternSuppressionState(ModelDoc2 model, swComponentSuppressionState_e suppressionState)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
var flatPattern = model.GetFeatureByTypeName("FlatPattern");
|
||||||
|
|
||||||
|
flatPattern.SetSuppression((int)suppressionState);
|
||||||
|
|
||||||
|
return flatPattern.IsSuppressed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string RemoveXmlTags(string input)
|
||||||
|
{
|
||||||
|
// Define the regular expression pattern to match XML tags
|
||||||
|
string pattern = @"<[^>]+>";
|
||||||
|
|
||||||
|
// Replace all matches of the pattern with an empty string
|
||||||
|
string result = Regex.Replace(input, pattern, "");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -51,22 +51,42 @@ namespace ExportDXF.ItemExtractors
|
|||||||
|
|
||||||
if (columnIndices.ItemNumber != -1)
|
if (columnIndices.ItemNumber != -1)
|
||||||
{
|
{
|
||||||
item.ItemNo = table.DisplayedText[rowIndex, columnIndices.ItemNumber];
|
var x = table.DisplayedText[rowIndex, columnIndices.ItemNumber];
|
||||||
|
x = Helper.RemoveXmlTags(x);
|
||||||
|
|
||||||
|
double d;
|
||||||
|
|
||||||
|
if (double.TryParse(x, out d))
|
||||||
|
{
|
||||||
|
item.ItemNo = d.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.ItemNo = x;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnIndices.PartNumber != -1)
|
if (columnIndices.PartNumber != -1)
|
||||||
{
|
{
|
||||||
item.PartName = table.DisplayedText[rowIndex, columnIndices.PartNumber];
|
var x = table.DisplayedText[rowIndex, columnIndices.PartNumber];
|
||||||
|
x = Helper.RemoveXmlTags(x);
|
||||||
|
|
||||||
|
item.PartName = x;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnIndices.Description != -1)
|
if (columnIndices.Description != -1)
|
||||||
{
|
{
|
||||||
item.Description = table.DisplayedText[rowIndex, columnIndices.Description];
|
var x = table.DisplayedText[rowIndex, columnIndices.Description];
|
||||||
|
x = Helper.RemoveXmlTags(x);
|
||||||
|
|
||||||
|
item.Description = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columnIndices.Quantity != -1)
|
if (columnIndices.Quantity != -1)
|
||||||
{
|
{
|
||||||
var qtyString = table.DisplayedText[rowIndex, columnIndices.Quantity];
|
var qtyString = table.DisplayedText[rowIndex, columnIndices.Quantity];
|
||||||
|
qtyString = Helper.RemoveXmlTags(qtyString);
|
||||||
|
|
||||||
int qty = 0;
|
int qty = 0;
|
||||||
int.TryParse(qtyString, out qty);
|
int.TryParse(qtyString, out qty);
|
||||||
|
|||||||
@@ -301,17 +301,8 @@ namespace ExportDXF
|
|||||||
|
|
||||||
public static bool HasSupressedBends(IView view)
|
public static bool HasSupressedBends(IView view)
|
||||||
{
|
{
|
||||||
var model = view.ReferencedDocument;
|
var model = GetModelFromView(view);
|
||||||
var refConfig = view.ReferencedConfiguration;
|
|
||||||
model.ShowConfiguration(refConfig);
|
|
||||||
|
|
||||||
var flatPattern = model.GetFeatureByTypeName("FlatPattern");
|
var flatPattern = model.GetFeatureByTypeName("FlatPattern");
|
||||||
|
|
||||||
if (flatPattern.IsSuppressed())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var bends = flatPattern.GetAllSubFeaturesByTypeName("UiBend");
|
var bends = flatPattern.GetAllSubFeaturesByTypeName("UiBend");
|
||||||
|
|
||||||
foreach (var bend in bends)
|
foreach (var bend in bends)
|
||||||
@@ -323,5 +314,14 @@ namespace ExportDXF
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ModelDoc2 GetModelFromView(IView view)
|
||||||
|
{
|
||||||
|
var model = view.ReferencedDocument;
|
||||||
|
var refConfig = view.ReferencedConfiguration;
|
||||||
|
model.ShowConfiguration(refConfig);
|
||||||
|
|
||||||
|
return model;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user