Skip to content

Commit f4dbb24

Browse files
committed
v. 0.3.0
Added the feature to split body by faces
1 parent 86ff39e commit f4dbb24

File tree

11 files changed

+159
-41
lines changed

11 files changed

+159
-41
lines changed

Installer/AddInReg.wxs

Lines changed: 47 additions & 35 deletions
Large diffs are not rendered by default.

Installer/Product.wxs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
3-
<Product Id="*" Name="Geometry++" Language="1033" Version="0.2.0.0" Manufacturer="CodeStack" UpgradeCode="{56083FFE-D237-4BC0-A853-BA1C65BC9F68}">
3+
<Product Id="*" Name="Geometry++" Language="1033" Version="0.3.0.0" Manufacturer="CodeStack" UpgradeCode="{56083FFE-D237-4BC0-A853-BA1C65BC9F68}">
44
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
55

66
<MajorUpgrade DowngradeErrorMessage="A newer version of Geometry++ is already installed." />

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,9 @@ This command allows extruding the surface and adding the caps at the ends of ext
2222
### Bodies Fillet
2323
![Bodies Fillet](https://www.codestack.net/labs/solidworks/geometry-plus-plus/user-guide/body-fillet/icon.png)
2424

25-
This command allows adding the fillet to entire bodies, faces, edges and vertices supporting multiple bodies within a single feature
25+
This command allows adding the fillet to entire bodies, faces, edges and vertices supporting multiple bodies within a single feature
26+
27+
### Split Body By Faces
28+
![Split Body By Faces](https://www.codestack.net/labs/solidworks/geometry-plus-plus/user-guide/split-body-by-faces/icon.png)
29+
30+
This command allows creating of surface (sheet) bodies from all the faces of input solid or surface bodies.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using CodeStack.Community.GeometryPlusPlus.Properties;
2+
using CodeStack.SwEx.MacroFeature.Attributes;
3+
using CodeStack.SwEx.PMPage.Attributes;
4+
using SolidWorks.Interop.sldworks;
5+
using SolidWorks.Interop.swconst;
6+
using System;
7+
using System.Collections.Generic;
8+
using System.ComponentModel;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
13+
namespace CodeStack.Community.GeometryPlusPlus.Features.SplitBodyByFaces
14+
{
15+
[Message("Select solid or surface bodies to convert faces to surface bodies", "Split Body By Faces")]
16+
[Help("https://www.codestack.net/labs/solidworks/geometry-plus-plus/user-guide/split-body-by-faces/")]
17+
public class SplitBodyByFacesDataModel
18+
{
19+
[SelectionBox(swSelectType_e.swSelSOLIDBODIES, swSelectType_e.swSelSURFACEBODIES)]
20+
[ParameterEditBody]
21+
[ControlAttribution(swControlBitmapLabelType_e.swBitmapLabel_SelectFaceSurface)]
22+
[ControlOptions(height: 60)]
23+
[Description("Solid or sheet bodies to convert faces to surface bodies")]
24+
public List<IBody2> Bodies { get; set; }
25+
}
26+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
using CodeStack.Community.GeometryPlusPlus.Base;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using SolidWorks.Interop.sldworks;
8+
using CodeStack.Community.GeometryPlusPlus.Exceptions;
9+
using CodeStack.Community.GeometryPlusPlus.Properties;
10+
using CodeStack.SwEx.MacroFeature.Attributes;
11+
using System.Runtime.InteropServices;
12+
using SolidWorks.Interop.swconst;
13+
using System.ComponentModel;
14+
15+
namespace CodeStack.Community.GeometryPlusPlus.Features.SplitBodyByFaces
16+
{
17+
[SwEx.Common.Attributes.Icon(typeof(Resources), nameof(Resources.split_body_by_faces))]
18+
[SwEx.Common.Attributes.Title("Split Body By Faces")]
19+
[Description("Converts solid or surface bodies faces to surface bodies")]
20+
[Options("SplitBodyByFaces", PROVIDER_MSG)]
21+
[SwEx.Common.Attributes.LoggerOptions(true, AddIn.LOGGER_NAME + ".SplitBodyByFacesMacroFeature")]
22+
[ComVisible(true), ProgId(PROG_ID), Guid("491EC32F-F879-4BFF-9C51-86AD93BA06E2")]
23+
public class SplitBodyByFacesMacroFeature : GeometryMacroFeature<SplitBodyByFacesDataModel>
24+
{
25+
internal const string PROG_ID = "CodeStack.GeometryPlusPlus.SplitBodyByFacesMacroFeature";
26+
27+
protected override IBody2[] CreateGeometry(ISldWorks app, SplitBodyByFacesDataModel parameters)
28+
{
29+
if (parameters.Bodies != null && parameters.Bodies.Any())
30+
{
31+
var modeler = app.IGetModeler();
32+
33+
var resBodies = new List<IBody2>();
34+
35+
foreach (var body in parameters.Bodies)
36+
{
37+
var faces = (body.GetFaces() as object[]).Cast<IFace2>().ToArray();
38+
39+
foreach (var face in faces)
40+
{
41+
var sheetBody = modeler.CreateSheetFromFaces(new IFace2[] { face });
42+
43+
resBodies.Add(sheetBody);
44+
}
45+
}
46+
47+
return resBodies.ToArray();
48+
}
49+
else
50+
{
51+
throw new UserErrorException("No input bodies selected");
52+
}
53+
}
54+
}
55+
}

Sw/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("CodeStack")]
1212
[assembly: AssemblyProduct("Geometry++")]
13-
[assembly: AssemblyCopyright("Copyright © www.codestack.net 2018")]
13+
[assembly: AssemblyCopyright("Copyright © www.codestack.net 2019")]
1414
[assembly: AssemblyTrademark("")]
1515
[assembly: AssemblyCulture("")]
1616

1717
[assembly: ComVisible(false)]
1818

1919
[assembly: Guid("060b3bc3-0502-4903-96c8-35823ac63a50")]
2020

21-
[assembly: AssemblyVersion("0.2.0.0")]
22-
[assembly: AssemblyFileVersion("0.2.0.0")]
21+
[assembly: AssemblyVersion("0.3.0.0")]
22+
[assembly: AssemblyFileVersion("0.3.0.0")]
2323

2424
[assembly: UpdatesUrl(typeof(Resources), nameof(Resources.UpdateUrl))]
2525

Sw/Properties/Resources.Designer.cs

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sw/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,7 @@
175175
<data name="crop_bodies" type="System.Resources.ResXFileRef, System.Windows.Forms">
176176
<value>..\Resources\crop-bodies.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
177177
</data>
178+
<data name="split_body_by_faces" type="System.Resources.ResXFileRef, System.Windows.Forms">
179+
<value>..\Resources\split-body-by-faces.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
180+
</data>
178181
</root>
9.04 KB
Loading

Sw/ServicesContainer.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using CodeStack.Community.GeometryPlusPlus.Features.CropBodies;
55
using CodeStack.Community.GeometryPlusPlus.Features.ExtrudeSurfaceCap;
66
using CodeStack.Community.GeometryPlusPlus.Features.SolidToSurface;
7+
using CodeStack.Community.GeometryPlusPlus.Features.SplitBodyByFaces;
78
using SolidWorks.Interop.sldworks;
89
using System;
910
using System.Collections.Generic;
@@ -85,6 +86,7 @@ private IEnumerable<IGeometryMacroFeature> RegisterGeometryFeatures()
8586
yield return new CropBodiesMacroFeature();
8687
yield return new ExtrudeSurfaceCapMacroFeature();
8788
yield return new BodiesFilletMacroFeature();
89+
yield return new SplitBodyByFacesMacroFeature();
8890
}
8991

9092
private bool OnHandleError(Exception ex)

0 commit comments

Comments
 (0)