├── .gitignore
├── .gitmodules
├── ApiTest
├── .upgrade-assistant
├── ApiTest.csproj
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ └── launchSettings.json
├── obj
│ └── Debug
│ │ ├── ApiTest.csproj.CoreCompileInputs.cache
│ │ ├── ApiTest.csprojAssemblyReference.cache
│ │ └── DesignTimeResolveAssemblyReferencesInput.cache
└── upgrade-assistant.clef
├── CSharpCad6
├── Application.cs
├── CSharpCad6.csproj
├── MatterCadGuiWidget.cs
├── Program.cs
├── Properties
│ └── launchSettings.json
└── RootSystemWindow.cs
├── CommandLineExamples
├── BedLevelMount
│ ├── BedLevelMount.csproj
│ ├── MatterCad.cs
│ ├── MatterCad.sln
│ └── Properties
│ │ └── launchSettings.json
├── DialGaugeMount
│ ├── DialGaugeMount.csproj
│ ├── MatterCad.cs
│ └── Properties
│ │ └── launchSettings.json
├── PowerSupplyMountingFeet
│ ├── MatterCad.cs
│ ├── PowerSupplyMountingFeet.csproj
│ └── Properties
│ │ └── launchSettings.json
├── SpoolBarHolderM90
│ ├── MatterCad.cs
│ ├── Properties
│ │ └── launchSettings.json
│ └── SpoolBarHolderM90.csproj
├── SpoolBearingHolder
│ ├── MatterCad.cs
│ └── SpoolBearingHolder.csproj
├── StepArmForHobbit
│ ├── MatterCad.cs
│ └── StepArmForHobbit.csproj
├── TPBinoculars
│ ├── MatterCad.cs
│ ├── Properties
│ │ └── launchSettings.json
│ └── TPBinoculars.csproj
└── TrainConnector
│ ├── MatterCad.cs
│ └── TrainConnector.csproj
├── DinamiclyExecuteCode
├── App.config
├── CodeHelper.cs
├── DynCode.csproj
├── DynCode.sln
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── LICENSE
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Screenshot.png
└── readme.md
├── Examples
├── LinearExtrude.cs
├── Rotate.cs
└── snippet.cs
├── MatterCAD - Design Your 3D Parts In C# MatterHackers.html
├── MatterCAD - Design Your 3D Parts In C# MatterHackers_files
├── 313538905788064.js
├── 561989750567702.js
├── 7CVkr2ch1PloVxbPqSkQtyv1TfDuILg19h8WlTspCtlxPAt4c3GhPoJoh0Ru.png
├── AAWq6WJ0tMYkC_MlRyt1V6VicoC-fUOi_MRZe3QcifHrVlSxqigtER-W1oEi.png
├── DAIz90qRgmQZjCftT5ejMJYsvKBV4nh4FFUJPCXtyJ5cBOe1L6h5KYNxT16U.png
├── LKN3IOS7AZCE3JS3ZJFFRF
├── ZUuuDWD2Z6h2vt3s8qyj3t05ZCkOp3_YsJAQQ6A8C3jV-9jPQ0LJi2Hc-AMv.png
├── a
├── bruha-plugins.js
├── bruha-scripts.js
├── conversion.js
├── css.css
├── dc.js
├── easy-affiliate.js
├── f_AKhimVj4TU5JGlBQ4l9MQCyAb9i_iIAK1RXgK61Mbf_oigBZVKzvnrgrw9.png
├── fbevents.js
├── jquery.js
├── mh-icon.png
├── mh-logo-themed-pixelfit.svg
├── mh-logo-white.svg
├── out.gif
├── out.html
├── out.txt
├── out_002.gif
├── out_002.html
├── out_003.gif
├── out_004.gif
├── out_005.gif
├── out_006.gif
├── out_007.gif
├── public-article.js
├── public-plugins.css
├── public-revised.css
└── roundtrip.js
├── MatterCadGui
├── .vs
│ └── MatterCadGui
│ │ └── v14
│ │ └── .suo
├── CsgEdtors
│ ├── CsgEditorBase.cs
│ ├── CsgEditorBox.cs
│ ├── CsgEditorTranslate.cs
│ └── CsgEditorUnion.cs
├── Logo.png
├── MatterCadGui.cs
├── MatterCadGui.csproj
├── MatterCadGui.csproj.user
├── MatterCadGui.sln
├── MatterCadGuiWidget.cs
├── Microsoft.Scripting.dll
├── OrthographicZProjection.cs
├── Parts
│ ├── PSEyeHolder.cs
│ ├── TrainConnector.cs
│ └── test.part
├── PowerSupply.cs
└── app.config
├── OpenCSharpCad
├── .gitignore
├── App.config
├── MainWindow.cs
├── OpenCSharpCad.csproj
├── Properties
│ └── AssemblyInfo.cs
└── Shapes.cs
├── OpenSharpCAD.sln
├── README.md
├── Screenshot 2018-03-30 22.56.56.png
├── Screenshot 2018-03-30 22.57.39.png
└── WindowTest
├── App.config
├── Program.cs
├── Properties
└── AssemblyInfo.cs
└── WindowTest.csproj
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3 | ################################################################################
4 |
5 | /MatterCadGui/bin/Debug
6 | .vs
7 | [Bb]in
8 | [Oo]bj
9 | packages
10 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "Submodules/agg-sharp"]
2 | path = Submodules/agg-sharp
3 | url = https://github.com/MatterHackers/agg-sharp.git
4 | branch = dot_net6
5 |
--------------------------------------------------------------------------------
/ApiTest/.upgrade-assistant:
--------------------------------------------------------------------------------
1 | {"Build":"0.3.326103\u002B3dfe0925b5198e8bb4cae20f02bfd968e95eb1e8","CurrentProject":"","EntryPoints":["ApiTest.csproj"],"Properties":{"BaseBackupLocation":"C:\\Users\\roboter\\Documents\\GitHub\\OpenSharpCAD\\ApiTest.backup"}}
--------------------------------------------------------------------------------
/ApiTest/ApiTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0-windows
4 | Exe
5 | false
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | all
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ApiTest/Program.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Csg;
2 | using MatterHackers.Csg.Processors;
3 | using MatterHackers.Csg.Solids;
4 | using MatterHackers.VectorMath;
5 |
6 | namespace ApiTest
7 | {
8 | class Program
9 | {
10 |
11 | private static CsgObject Render()
12 | {
13 | CsgObject box = new Box(100, 100, 100);
14 | //return box;
15 | //CsgObject cylinder = new Cylinder(50, 50, 50);
16 | // return cylinder;
17 | //CsgObject tor = new Torus(10, 20);
18 | //return tor;
19 |
20 | Round round = new Round(100, 100, 100);
21 | round.RoundFace(Face.Front, 10);
22 | // return box-round;
23 |
24 | return new LinearExtrude(new[] { new Vector2(0, 0), new Vector2(0,10), new Vector2(10,10) }, 10);
25 | }
26 |
27 | static void Main()
28 | {
29 | CsgObject bedLevelMount = Render();
30 | OpenSCadOutput.Save(bedLevelMount, "test.scad");
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/ApiTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("ApiTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("ApiTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("46c6bea2-032e-47cc-a027-9d53afb716f1")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/ApiTest/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "ApiTest": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/ApiTest/obj/Debug/ApiTest.csproj.CoreCompileInputs.cache:
--------------------------------------------------------------------------------
1 | 75a6a5afc95bb7493c027301f438800fe597c6fc
2 |
--------------------------------------------------------------------------------
/ApiTest/obj/Debug/ApiTest.csprojAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/ApiTest/obj/Debug/ApiTest.csprojAssemblyReference.cache
--------------------------------------------------------------------------------
/ApiTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/ApiTest/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
--------------------------------------------------------------------------------
/CSharpCad6/Application.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Agg;
2 | using MatterHackers.Agg.UI;
3 | using System;
4 | using System.Diagnostics;
5 | using System.Threading.Tasks;
6 |
7 | namespace OpenCSharpCad;
8 |
9 | public static class Application
10 | {
11 | private static ProgressBar progressBar;
12 | private static TextWidget statusText;
13 | private static FlowLayoutWidget progressPanel;
14 | private static string lastSection = "";
15 | private static Stopwatch timer;
16 |
17 | public static bool EnableF5Collect { get; set; }
18 |
19 | public static bool EnableNetworkTraffic { get; set; } = true;
20 |
21 | //public GuiWidget CreateSearchButton()
22 | //{
23 | // return new IconButton(StaticData.Instance.LoadIcon("icon_search_24x24.png", 16, 16).SetToColor(TextColor), this)
24 | // {
25 | // ToolTipText = "Search".Localize(),
26 | // };
27 | //}
28 |
29 | public static RootSystemWindow LoadRootWindow(int width, int height)
30 | {
31 | timer = Stopwatch.StartNew();
32 |
33 | //if (false)
34 | //{
35 | // // set the default font
36 | // AggContext.DefaultFont = ApplicationController.GetTypeFace(NamedTypeFace.Nunito_Regular);
37 | // AggContext.DefaultFontBold = ApplicationController.GetTypeFace(NamedTypeFace.Nunito_Bold);
38 | // AggContext.DefaultFontItalic = ApplicationController.GetTypeFace(NamedTypeFace.Nunito_Italic);
39 | // AggContext.DefaultFontBoldItalic = ApplicationController.GetTypeFace(NamedTypeFace.Nunito_Bold_Italic);
40 | //}
41 |
42 | var rootSystemWindow = new RootSystemWindow(width, height);
43 |
44 |
45 | //// var searchButton = theme.CreateSearchButton();
46 | // searchButton.Name = "App Search Button";
47 | // searchButton.MouseDown += (s, e) =>
48 | // {
49 | // searchPanelOpenOnMouseDown = searchPanel != null;
50 | // };
51 |
52 | //// searchButton.Click += SearchButton_Click;
53 | // rootSystemWindow.AddChild(searchButton);
54 |
55 |
56 |
57 | //var overlay = new GuiWidget()
58 | //{
59 | // BackgroundColor = Color.White//ppContext.Theme.BackgroundColor,
60 | //};
61 | //overlay.AnchorAll();
62 |
63 | //rootSystemWindow.AddChild(overlay);
64 |
65 | //progressPanel = new FlowLayoutWidget(FlowDirection.TopToBottom)
66 | //{
67 | // Position = new Vector2(0, height * .25),
68 | // HAnchor = HAnchor.Center | HAnchor.Fit,
69 | // VAnchor = VAnchor.Fit,
70 | // MinimumSize = new Vector2(400, 100),
71 | // Margin = new BorderDouble(0, 0, 0, 200)
72 | //};
73 | //overlay.AddChild(progressPanel);
74 |
75 | //progressPanel.AddChild(statusText = new TextWidget("", textColor: Color.Black)
76 | //{
77 | // MinimumSize = new Vector2(200, 30),
78 | // HAnchor = HAnchor.Center,
79 | // AutoExpandBoundsToText = true
80 | //});
81 |
82 | //progressPanel.AddChild(progressBar = new ProgressBar()
83 | //{
84 | // FillColor = Color.Pink,
85 | // BorderColor = Color.Gray, // theme.BorderColor75,
86 | // Height = 11 * GuiWidget.DeviceScale,
87 | // Width = 230 * GuiWidget.DeviceScale,
88 | // HAnchor = HAnchor.Center,
89 | // VAnchor = VAnchor.Absolute
90 | //});
91 |
92 | // AppContext.RootSystemWindow = rootSystemWindow;
93 |
94 | // Hook SystemWindow load and spin up MatterControl once we've hit first draw
95 | rootSystemWindow.Load += (s, e) =>
96 | {
97 |
98 |
99 | LoadMC();
100 |
101 | };
102 |
103 |
104 | void LoadMC()
105 | {
106 | // ReportStartupProgress(0.02, "First draw->RunOnIdle");
107 |
108 | // UiThread.RunOnIdle(() =>
109 | Task.Run(async () =>
110 | {
111 | try
112 | {
113 | // ReportStartupProgress(0.15, "MatterControlApplication.Initialize");
114 |
115 | // ApplicationController.LoadTranslationMap();
116 |
117 | //var mainView = await Initialize(rootSystemWindow, (progress0To1, status) =>
118 | //{
119 | ////// ReportStartupProgress(0.2 + progress0To1 * 0.7, status);
120 | //});
121 |
122 | // ReportStartupProgress(0.9, "AddChild->MainView");
123 | // rootSystemWindow.AddChild(mainView, 0);
124 |
125 | // ReportStartupProgress(1, "");
126 | rootSystemWindow.BackgroundColor = Color.Transparent;
127 | // overlay.Close();
128 | }
129 | catch (Exception ex)
130 | {
131 | UiThread.RunOnIdle(() =>
132 | {
133 | statusText.Visible = false;
134 |
135 | var errorTextColor = Color.White;
136 |
137 | progressPanel.Margin = 0;
138 | progressPanel.VAnchor = VAnchor.Center | VAnchor.Fit;
139 | progressPanel.BackgroundColor = Color.DarkGray;
140 | progressPanel.Padding = 20;
141 | progressPanel.Border = 1;
142 | progressPanel.BorderColor = Color.Red;
143 |
144 | // var theme = new ThemeConfig();
145 |
146 | progressPanel.AddChild(
147 | new TextWidget("Startup Failure:", pointSize: 10, textColor: errorTextColor));
148 |
149 | progressPanel.AddChild(
150 | new TextWidget(ex.Message, pointSize: 10, textColor: errorTextColor));
151 |
152 | //var closeButton = new TextButton("Close", theme)
153 | //{
154 | // BackgroundColor = theme.SlightShade,
155 | // HAnchor = HAnchor.Right,
156 | // VAnchor = VAnchor.Absolute
157 | //};
158 | //closeButton.Click += (s1, e1) =>
159 | //{
160 | // rootSystemWindow.Close();
161 | //};
162 |
163 | //spinner.SpinLogo = false;
164 | progressBar.Visible = false;
165 |
166 | // progressPanel.AddChild(closeButton);
167 | });
168 | }
169 |
170 | // AppContext.IsLoading = false;
171 | });
172 | }
173 |
174 |
175 | return rootSystemWindow;
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/CSharpCad6/CSharpCad6.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0-windows
4 | Release
5 | WinExe
6 | true
7 | CSharpCAD
8 | CSharpCAD
9 | False
10 | False
11 | Auto
12 | 4194304
13 | 4096
14 | false
15 | publish\
16 | true
17 | Disk
18 | false
19 | Foreground
20 | 7
21 | Days
22 | false
23 | false
24 | true
25 | 0
26 | 1.0.0.%2a
27 | false
28 | true
29 | false
30 |
31 |
32 | True
33 | MinimumRecommendedRules.ruleset
34 |
35 |
36 | none
37 | MinimumRecommendedRules.ruleset
38 |
39 |
40 | bin\x64\Debug\
41 | true
42 | 4096
43 | AllRules.ruleset
44 | false
45 | false
46 |
47 |
48 | bin\x64\Release\
49 | 4096
50 | AllRules.ruleset
51 | false
52 | false
53 |
54 |
55 |
56 | False
57 | .NET Framework 3.5 SP1 Client Profile
58 | false
59 |
60 |
61 | False
62 | .NET Framework 3.5 SP1
63 | true
64 |
65 |
66 | False
67 | Windows Installer 3.1
68 | true
69 |
70 |
71 |
72 |
73 |
74 | all
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
--------------------------------------------------------------------------------
/CSharpCad6/MatterCadGuiWidget.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Agg;
2 | using MatterHackers.Agg.UI;
3 | using System;
4 | using System.Diagnostics;
5 | using Vector2 = MatterHackers.VectorMath.Vector2;
6 |
7 | namespace OpenCSharpCad;
8 |
9 | class MatterCadGuiWidget : SystemWindow
10 | {
11 | public static bool UseGl { get; set; } = true;
12 |
13 | private static Vector2 minSize { get; set; } = new Vector2(600, 480);
14 |
15 | private Stopwatch totalDrawTime = new Stopwatch();
16 |
17 | private AverageMillisecondTimer millisecondTimer = new AverageMillisecondTimer();
18 |
19 | public static bool ShowMemoryUsed = true;
20 |
21 | private int drawCount = 0;
22 |
23 | public MatterCadGuiWidget(double width, double height) : base(width, height)
24 | {
25 |
26 | this.Name = "MatterControl";
27 | this.Padding = new BorderDouble(0); // To be re-enabled once native borders are turned off
28 | this.AnchorAll();
29 |
30 | GuiWidget.DefaultEnforceIntegerBounds = true;
31 |
32 | // TODO: Needs review - doesn't seem like we want to scale on Touchscreen, rather we want device specific, configuration based scaling. Suggest remove
33 | if (GuiWidget.TouchScreenMode)
34 | {
35 | // TODO: This steps on user scaling
36 | GuiWidget.DeviceScale = 1.3;
37 | SystemWindow.ShareSingleOsWindow = true;
38 | }
39 |
40 | string textSizeMode = "10";// UserSettings.Instance.get(UserSettingsKey.ApplicationTextSize);
41 | if (!string.IsNullOrEmpty(textSizeMode))
42 | {
43 | if (double.TryParse(textSizeMode, out double textSize))
44 | {
45 | GuiWidget.DeviceScale = textSize;
46 | }
47 | }
48 |
49 | UseOpenGL = UseGl;
50 |
51 | this.SetStartupTraits();
52 | }
53 |
54 | public void SetStartupTraits()
55 | {
56 | string version = "2.0";
57 |
58 | this.MinimumSize = minSize;
59 |
60 | this.Title = $"1223";
61 |
62 |
63 | this.Title += string.Format(" - {0}Bit", IntPtr.Size == 4 ? 32 : 64);
64 |
65 |
66 | this.DesktopPosition = new Point2D(-1, -1);
67 |
68 | this.Maximized = false;
69 | }
70 |
71 | public override void OnDraw(Graphics2D graphics2D)
72 | {
73 | totalDrawTime.Restart();
74 | GuiWidget.DrawCount = 0;
75 | using (new PerformanceTimer("Draw Timer", "MC Draw"))
76 | {
77 | base.OnDraw(graphics2D);
78 | }
79 |
80 | totalDrawTime.Stop();
81 |
82 | millisecondTimer.Update((int)totalDrawTime.ElapsedMilliseconds);
83 |
84 | if (ShowMemoryUsed)
85 | {
86 | long memory = GC.GetTotalMemory(false);
87 | this.Title = $"Allocated = {memory:n0} : {millisecondTimer.GetAverage()}ms, d{drawCount++} Size = {this.Width}x{this.Height}, onIdle = {UiThread.CountExpired}:{UiThread.Count}, widgetsDrawn = {GuiWidget.DrawCount}";
88 | }
89 |
90 | // msGraph.AddData("ms", totalDrawTime.ElapsedMilliseconds);
91 | // msGraph.Draw(MatterHackers.Agg.Transform.Affine.NewIdentity(), graphics2D);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/CSharpCad6/Program.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Agg.Platform;
2 | using System;
3 | using System.Globalization;
4 | using System.Threading;
5 |
6 | namespace OpenCSharpCad;
7 |
8 | class Program
9 | {
10 | [STAThread]
11 | static void Main(string[] args)
12 | {
13 | // Set the global culture for the app, current thread and all new threads
14 | CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
15 | CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
16 | Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
17 | Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
18 | var (width, height) = RootSystemWindow.GetStartupBounds();
19 |
20 | var main = Application.LoadRootWindow(width, height);
21 |
22 | // Set default Agg providers
23 | AggContext.Config.ProviderTypes.SystemWindowProvider = "MatterHackers.GlfwProvider.GlfwWindowProvider, MatterHackers.GlfwProvider";
24 |
25 | main.ShowAsSystemWindow();
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/CSharpCad6/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "CSharpCad6": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/CSharpCad6/RootSystemWindow.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Agg;
2 | using MatterHackers.Agg.Platform;
3 | using MatterHackers.Agg.UI;
4 | using System;
5 | using System.Diagnostics;
6 | using Vector2 = MatterHackers.VectorMath.Vector2;
7 |
8 | namespace OpenCSharpCad;
9 |
10 | public class RootSystemWindow : SystemWindow
11 | {
12 | public static bool UseGl { get; set; } = true;
13 |
14 | private static Vector2 minSize { get; set; } = new Vector2(600, 480);
15 |
16 | private Stopwatch totalDrawTime = new Stopwatch();
17 |
18 | private AverageMillisecondTimer millisecondTimer = new AverageMillisecondTimer();
19 |
20 | public static bool ShowMemoryUsed = false;
21 |
22 | private int drawCount = 0;
23 |
24 | private bool exitDialogOpen = false;
25 |
26 | public RootSystemWindow(double width, double height)
27 | : base(width, height)
28 | {
29 | this.Name = "MatterControl";
30 | this.Padding = new BorderDouble(0); // To be re-enabled once native borders are turned off
31 | this.AnchorAll();
32 |
33 |
34 | var prevLayerButton = new Button("<<", 0, 0);
35 | // prevLayerButton.Click += prevLayer_ButtonClick;
36 | this.AddChild(prevLayerButton);
37 | this.AnchorAll();
38 |
39 | var textEditWidget = new TextEditWidget("Edit Me", 0, 0, 12);
40 |
41 | this.AddChild(textEditWidget);
42 |
43 | this.AnchorAll();
44 |
45 | GuiWidget.DefaultEnforceIntegerBounds = true;
46 |
47 | // TODO: Needs review - doesn't seem like we want to scale on Touchscreen, rather we want device specific, configuration based scaling. Suggest remove
48 | if (GuiWidget.TouchScreenMode)
49 | {
50 | // TODO: This steps on user scaling
51 | GuiWidget.DeviceScale = 1.3;
52 | SystemWindow.ShareSingleOsWindow = true;
53 | }
54 |
55 | string textSizeMode = String.Empty;
56 | if (!string.IsNullOrEmpty(textSizeMode))
57 | {
58 | if (double.TryParse(textSizeMode, out double textSize))
59 | {
60 | GuiWidget.DeviceScale = textSize;
61 | }
62 | }
63 |
64 | UseOpenGL = UseGl;
65 | }
66 |
67 | public static (int width, int height) GetStartupBounds(int overrideWidth = -1, int overrideHeight = -1)
68 | {
69 | int width = 0;
70 | int height = 0;
71 | if (GuiWidget.TouchScreenMode)
72 | {
73 | minSize = new Vector2(800, 480);
74 | }
75 |
76 |
77 | Point2D desktopSize = AggContext.DesktopSize;
78 |
79 | if (overrideWidth != -1)
80 | {
81 | width = overrideWidth;
82 | }
83 | else // try to set it to a good size
84 | {
85 | if (width < desktopSize.x)
86 | {
87 | width = 1280;
88 | }
89 | }
90 |
91 | if (overrideHeight != -1)
92 | {
93 | // Height should be constrained to actual
94 | height = Math.Min(overrideHeight, desktopSize.y);
95 | }
96 | else
97 | {
98 | if (height < desktopSize.y)
99 | {
100 | height = 720;
101 | }
102 | }
103 |
104 |
105 | return (width, height);
106 | }
107 | }
--------------------------------------------------------------------------------
/CommandLineExamples/BedLevelMount/BedLevelMount.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 |
8 |
9 |
10 | true
11 |
12 |
13 | none
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | all
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CommandLineExamples/BedLevelMount/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Csg;
2 | using MatterHackers.Csg.Solids;
3 | using MatterHackers.Csg.Transform;
4 | using MatterHackers.Csg.Processors;
5 | using MatterHackers.VectorMath;
6 |
7 | namespace OpenSharpCadSnippet
8 | {
9 | static class RenderTest
10 | {
11 | //static void BedLevelTestCode()
12 | //{
13 | // Vector3 x20y20 = new Vector3(20, 20, 21.56);
14 | // Vector3 x120y20 = new Vector3(120, 20, 18.44);
15 | // Vector3 x20y120 = new Vector3(20, 120, 21.03);
16 |
17 | // Vector3 xPositive = (x120y20 - x20y20).GetNormal();
18 | // Vector3 yPositive = (x20y120 - x20y20).GetNormal();
19 | // Vector3 planNormal = Vector3.Cross(yPositive, xPositive);
20 |
21 | // Matrix4X4 bedLevel = Matrix4X4.LookAt(Vector3.Zero, planNormal, yPositive);
22 |
23 | // Vector3 fixedX20Y20 = Vector3.Transform(x20y20, bedLevel);
24 | // Vector3 fixedX120Y20 = Vector3.Transform(x120y20, bedLevel);
25 | // Vector3 fixedX20Y120 = Vector3.Transform(x20y120, bedLevel);
26 | // double zAtX0Y0 = fixedX120Y20.z;
27 |
28 | // Matrix4X4 inverseBedLevel = Matrix4X4.Invert(bedLevel);
29 |
30 | // bedLevel = Matrix4X4.Identity;
31 | // Matrix4X4 A = bedLevel;
32 | // Matrix4X4 result = new Matrix4X4();
33 | // double determinant = +A[0, 0] * (A[1, 1] * A[2, 2] - A[2, 1] * A[1, 2])
34 | // - A[0, 1] * (A[1, 0] * A[2, 2] - A[1, 2] * A[2, 0])
35 | // + A[0, 2] * (A[1, 0] * A[2, 1] - A[1, 1] * A[2, 0]);
36 | // double invdet = 1 / determinant;
37 | // result[0, 0] = (A[1, 1] * A[2, 2] - A[2, 1] * A[1, 2]) * invdet;
38 | // result[0, 1] = -(A[0, 1] * A[2, 2] - A[0, 2] * A[2, 1]) * invdet;
39 | // result[0, 2] = (A[0, 1] * A[1, 2] - A[0, 2] * A[1, 1]) * invdet;
40 | // result[1, 0] = -(A[1, 0] * A[2, 2] - A[1, 2] * A[2, 0]) * invdet;
41 | // result[1, 1] = (A[0, 0] * A[2, 2] - A[0, 2] * A[2, 0]) * invdet;
42 | // result[1, 2] = -(A[0, 0] * A[1, 2] - A[1, 0] * A[0, 2]) * invdet;
43 | // result[2, 0] = (A[1, 0] * A[2, 1] - A[2, 0] * A[1, 1]) * invdet;
44 | // result[2, 1] = -(A[0, 0] * A[2, 1] - A[2, 0] * A[0, 1]) * invdet;
45 | // result[2, 2] = (A[0, 0] * A[1, 1] - A[1, 0] * A[0, 1]) * invdet;
46 |
47 | // Vector3 stepPositionX20Y20 = Vector3.Transform(fixedX20Y20, inverseBedLevel);
48 | //}
49 |
50 | static double wallWidth = 4;
51 | static double switchHoleSeparation = 10;
52 | static double switchHoleDiameter = 2.5;
53 |
54 | static double switchHeight = 10;
55 | static double switchWidth = 20;
56 | static double armLength = 30;
57 | static double magnetHoldOffset = 15;
58 | static double pivotHeight = 11;
59 | static double pivotHoleRadius = 3.3;
60 | static double pivotRingRadius = pivotHoleRadius + wallWidth;
61 | static double magnetAttractorHoleRadius = 2.6;
62 | static double wireClearence = 6;
63 | static double magnetAttractorYSize = 8;
64 | static CsgObject OnOffArm()
65 | {
66 | CsgObject total;
67 |
68 | CsgObject mainBar = new Box(wallWidth * 1.5, 37, 2.5);
69 | total = mainBar;
70 |
71 | CsgObject magnetAttractorHole = new Cylinder(magnetAttractorHoleRadius / 2, mainBar.ZSize + .1, 2);
72 | magnetAttractorHole = new SetCenter(magnetAttractorHole, mainBar.GetCenter() + new Vector3(0, -magnetAttractorHoleRadius, 0));
73 |
74 | CsgObject magnetAttractorHole2 = new Cylinder(magnetAttractorHoleRadius / 2, mainBar.ZSize + .1, 2);
75 | magnetAttractorHole2 = new SetCenter(magnetAttractorHole2, mainBar.GetCenter() + new Vector3(0, magnetAttractorHoleRadius, 0));
76 |
77 | CsgObject bothHoles = magnetAttractorHole + magnetAttractorHole2;
78 | bothHoles = new Align(bothHoles, Face.Front, mainBar, Face.Front, offsetY: magnetAttractorHoleRadius);
79 |
80 | total -= bothHoles;
81 |
82 | CsgObject sideSupportBar = new Box(3, mainBar.YSize, mainBar.ZSize * 2);
83 | sideSupportBar = new Align(sideSupportBar, Face.Left | Face.Bottom, mainBar, Face.Right | Face.Bottom, -.02);
84 | total += sideSupportBar;
85 |
86 | CsgObject pressSpot = new Box(total.XSize, 5, total.ZSize);
87 | pressSpot = new Align(pressSpot, Face.Left | Face.Back | Face.Bottom, total, Face.Left | Face.Back | Face.Bottom);
88 | total += pressSpot;
89 |
90 | return total;
91 | }
92 |
93 | static double mountPivotHeight = 15;
94 | static double backMagnetHeight = 30;
95 | static double baseMagnetHeight = 7.5;
96 | static CsgObject MountMount()
97 | {
98 | Vector3 magnetSize = new Vector3(10, 5, 2.5);
99 |
100 | CsgObject total;
101 |
102 | CsgObject baseBox = new Box(37, 26, wallWidth * 2);
103 | Round baseBevels = new Round(baseBox.Size);
104 | baseBevels.RoundEdge(Edge.LeftFront, 4);
105 | baseBevels.RoundEdge(Edge.LeftBack, 4);
106 | baseBox -= baseBevels;
107 | CsgObject fakeXCarriage = new Translate(baseBox, 0.5);
108 | total = fakeXCarriage;
109 |
110 | double pivotRingYOffset = -pivotHeight / 2 - wallWidth / 2 - .5;
111 | CsgObject pivotRingFront = new Cylinder(pivotRingRadius / 2, wallWidth, 2);
112 | CsgObject pivotFrontWall = new Box(pivotRingRadius, wallWidth, mountPivotHeight);
113 | pivotFrontWall = new Translate(pivotFrontWall, 0, 0, -mountPivotHeight / 2);
114 | CsgObject pivotSupportFront = pivotRingFront + pivotFrontWall;
115 | CsgObject pivotHole = new Cylinder(pivotHoleRadius / 2, pivotRingFront.YSize + .1, 2);
116 | pivotHole = new SetCenter(pivotHole, pivotRingFront.GetCenter());
117 | pivotSupportFront -= pivotHole;
118 | pivotSupportFront = new Translate(pivotSupportFront, 0, pivotRingYOffset, mountPivotHeight);
119 | pivotSupportFront += Round.CreateFillet(pivotSupportFront, Face.Back, fakeXCarriage, Face.Top, 3);
120 | pivotSupportFront += Round.CreateFillet(pivotSupportFront, Face.Front, fakeXCarriage, Face.Top, 3);
121 | total += pivotSupportFront;
122 |
123 | CsgObject pivotSupportBack = pivotSupportFront.NewMirrorAccrossY();
124 | total += pivotSupportBack;
125 |
126 | CsgObject backMagnetHolder = new Box(wallWidth * 2, magnetSize.X + wallWidth, backMagnetHeight);
127 | backMagnetHolder = new Align(backMagnetHolder, Face.Bottom | Face.Right, fakeXCarriage, Face.Top | Face.Right, 0, 0, -.1);
128 | CsgObject backMagnetHole = new Box(magnetSize.Z, magnetSize.X, magnetSize.Y);
129 | backMagnetHole = new SetCenter(backMagnetHole, backMagnetHolder.GetCenter());
130 | backMagnetHole = new Align(backMagnetHole, Face.Left | Face.Top, backMagnetHolder, Face.Left | Face.Top, -.1, 0, -wallWidth / 2);
131 |
132 | total += Round.CreateFillet(backMagnetHolder, Face.Front, fakeXCarriage, Face.Top, 3);
133 | total += Round.CreateFillet(backMagnetHolder, Face.Back, fakeXCarriage, Face.Top, 3);
134 | total += Round.CreateFillet(backMagnetHolder, Face.Left, fakeXCarriage, Face.Top, 3);
135 |
136 | backMagnetHolder -= backMagnetHole;
137 | total += backMagnetHolder;
138 |
139 | CsgObject baseMagnetHolder = new Box(wallWidth * 2, magnetSize.X + wallWidth, baseMagnetHeight);
140 | baseMagnetHolder = new Align(baseMagnetHolder, Face.Bottom, fakeXCarriage, Face.Top, -14, 0, -.1);
141 | CsgObject baseMagnetHole = new Box(magnetSize.Y, magnetSize.X, magnetSize.Z);
142 | baseMagnetHole = new SetCenter(baseMagnetHole, baseMagnetHolder.GetCenter());
143 | baseMagnetHole = new Align(baseMagnetHole, Face.Top, baseMagnetHolder, Face.Top, 0, 0, .1);
144 | baseMagnetHolder -= baseMagnetHole;
145 | total += baseMagnetHolder;
146 |
147 | return total;
148 | }
149 |
150 | static CsgObject Render()
151 | {
152 | // CSG object is a Constructive Solid Geometry Object (a basic part in our system for doing boolean operations).
153 | CsgObject totalMount; // the csg object we will use as the master part.
154 |
155 | CsgObject pivotHole = new Cylinder(pivotHoleRadius / 2, pivotHeight + .1, 2);
156 |
157 | CsgObject pivotMount = new Cylinder(pivotRingRadius / 2, pivotHeight, 2);
158 | pivotMount = new Align(pivotMount, Face.Bottom, pivotHole, Face.Bottom, offsetZ: .02);
159 | totalMount = pivotMount;
160 |
161 | CsgObject holdArm = new Box(armLength, wallWidth * 2, wallWidth);
162 | holdArm = new Align(holdArm, Face.Left | Face.Front | Face.Bottom, pivotMount, Face.Left | Face.Front | Face.Bottom, offsetX: pivotRingRadius / 2);
163 | totalMount += holdArm;
164 |
165 | CsgObject switchMount = new Box(switchHeight, switchWidth, wallWidth);
166 | switchMount -= new Translate(new Cylinder(switchHoleDiameter / 2, switchMount.ZSize + .1 , 2), new Vector3(0, switchHoleSeparation / 2, 0));
167 | switchMount -= new Translate(new Cylinder(switchHoleDiameter / 2, switchMount.ZSize + .1, 2), new Vector3(0, -switchHoleSeparation / 2, 0));
168 | switchMount = new Align(switchMount, Face.Left | Face.Front | Face.Bottom, holdArm, Face.Right | Face.Front | Face.Bottom, offsetX: -.02, offsetY: -5);
169 | totalMount += switchMount;
170 |
171 | CsgObject magnetAttractor = new Box(wallWidth + magnetAttractorHoleRadius, magnetAttractorYSize, wallWidth * 3);
172 | // align it from the pivot point
173 | magnetAttractor = new Align(magnetAttractor, Face.Left | Face.Front | Face.Bottom, pivotMount, Face.Left | Face.Front | Face.Bottom, offsetX: magnetHoldOffset);
174 | totalMount += magnetAttractor;
175 |
176 | CsgObject bracingWall = new Box(wallWidth, wallWidth, pivotMount.ZSize - wallWidth);
177 | bracingWall = new SetCenter(bracingWall, holdArm.GetCenter());
178 | bracingWall = new Align(bracingWall, Face.Right | Face.Top, pivotMount, Face.Right | Face.Top);
179 | totalMount += bracingWall;
180 |
181 | CsgObject bracingArm = new Box(armLength - wireClearence, wallWidth, wallWidth);
182 | bracingArm = new SetCenter(bracingArm, holdArm.GetCenter());
183 | bracingArm = new Align(bracingArm, Face.Bottom | Face.Left, holdArm, Face.Top | Face.Left, offsetZ: -.1);
184 | totalMount += bracingArm;
185 |
186 | totalMount += Round.CreateFillet(bracingWall, Face.Right, bracingArm, Face.Top, 3);
187 | totalMount += Round.CreateFillet(bracingArm, Face.Right, holdArm, Face.Top, wallWidth);
188 |
189 | totalMount += Round.CreateFillet(holdArm, Face.Back, switchMount, Face.Left, wallWidth);
190 | totalMount += Round.CreateFillet(holdArm, Face.Front, switchMount, Face.Left, wallWidth);
191 |
192 | totalMount -= pivotHole;
193 |
194 | CsgObject magnetAttractorHole = new Cylinder(magnetAttractorHoleRadius / 2, magnetAttractor.YSize + .1, 2);
195 | magnetAttractorHole = new SetCenter(magnetAttractorHole, magnetAttractor.GetCenter() + new Vector3(0, 0, -magnetAttractorHoleRadius));
196 | totalMount -= magnetAttractorHole;
197 |
198 | CsgObject magnetAttractorHole2 = new Cylinder(magnetAttractorHoleRadius / 2, magnetAttractor.YSize + .1, 2);
199 | magnetAttractorHole2 = new SetCenter(magnetAttractorHole2, magnetAttractor.GetCenter() + new Vector3(0, 0, magnetAttractorHoleRadius));
200 | totalMount -= magnetAttractorHole2;
201 |
202 | return totalMount;
203 | }
204 |
205 | static void Main()
206 | {
207 |
208 | CsgObject bedLevelMount = Render();
209 | OpenSCadOutput.Save(bedLevelMount, "z-probe-mount.scad");
210 |
211 | CsgObject onOffArm = OnOffArm();
212 | OpenSCadOutput.Save(onOffArm, "up-down-bar.scad");
213 |
214 | bedLevelMount += new Translate(new Rotate(onOffArm, MathHelper.DegreesToRadians(90)), 14, -5, 13);
215 | CsgObject mount = new Rotate(bedLevelMount, MathHelper.DegreesToRadians(90));
216 | CsgObject mountRotations = new Rotate(mount, y: MathHelper.DegreesToRadians(-90));
217 | mountRotations += new Rotate(mount, y: MathHelper.DegreesToRadians(-170));
218 | mountRotations = new Translate(mountRotations, 6, -3.5, -30);
219 |
220 | CsgObject bedLevelMountMount = MountMount();
221 |
222 | bedLevelMountMount += new Translate(mountRotations, -6, 3.5, 45, "%up part");
223 |
224 | OpenSCadOutput.Save(bedLevelMountMount, "x-carriage-addition.scad");
225 | }
226 | }
227 | }
228 |
--------------------------------------------------------------------------------
/CommandLineExamples/BedLevelMount/MatterCad.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 11.00
3 | # Visual Studio 2010
4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterCad", "MatterCad.csproj", "{0B8D6F56-BD7F-4426-B858-D9292B084656}"
5 | EndProject
6 | Global
7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
8 | Debug|Any CPU = Debug|Any CPU
9 | Release|Any CPU = Release|Any CPU
10 | EndGlobalSection
11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
12 | {0B8D6F56-BD7F-4426-B858-D9292B084656}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13 | {0B8D6F56-BD7F-4426-B858-D9292B084656}.Debug|Any CPU.Build.0 = Debug|Any CPU
14 | {0B8D6F56-BD7F-4426-B858-D9292B084656}.Release|Any CPU.ActiveCfg = Release|Any CPU
15 | {0B8D6F56-BD7F-4426-B858-D9292B084656}.Release|Any CPU.Build.0 = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(SolutionProperties) = preSolution
18 | HideSolutionNode = FALSE
19 | EndGlobalSection
20 | GlobalSection(MonoDevelopProperties) = preSolution
21 | StartupItem = MatterCad.csproj
22 | EndGlobalSection
23 | EndGlobal
24 |
--------------------------------------------------------------------------------
/CommandLineExamples/BedLevelMount/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "BedLevelMount": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/CommandLineExamples/DialGaugeMount/DialGaugeMount.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 | False
8 | False
9 | Auto
10 | 4194304
11 | 4096
12 | publish\
13 | true
14 | Disk
15 | false
16 | Foreground
17 | 7
18 | Days
19 | false
20 | false
21 | true
22 | 0
23 | 1.0.0.%2a
24 | false
25 | false
26 | true
27 | false
28 |
29 |
30 | true
31 |
32 |
33 | none
34 |
35 |
36 |
37 |
38 |
39 |
40 | False
41 | .NET Framework 3.5 SP1 Client Profile
42 | false
43 |
44 |
45 | False
46 | .NET Framework 3.5 SP1
47 | true
48 |
49 |
50 | False
51 | Windows Installer 3.1
52 | true
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 | all
62 |
63 |
64 |
--------------------------------------------------------------------------------
/CommandLineExamples/DialGaugeMount/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Csg;
2 | using MatterHackers.Csg.Solids;
3 | using MatterHackers.Csg.Transform;
4 | using MatterHackers.Csg.Processors;
5 | using MatterHackers.VectorMath;
6 |
7 | namespace SimplePartScripting
8 | {
9 | static class SimplePartTester
10 | {
11 | static double xCarriageDistanceBetweenBars = 47.8;
12 | static double xCarriageBarWidth = 8;
13 | static double xCarriageSeparation = xCarriageDistanceBetweenBars + xCarriageBarWidth;
14 | static double diameterOfDialGaugeBar = 9.5 + .3;
15 | static double wallWidth = 4;
16 | static double wallHeight = 15;
17 | static double dialGaugeBarOffsetFromCenter = 10;
18 |
19 | static CsgObject DialGaugeMount()
20 | {
21 | // CSG object is a Constructive Solid Geometry Object (a basic part in our system for doing boolean operations).
22 | CsgObject dialGauge; // the csg object we will use as the master part.
23 |
24 | CsgObject frontBarRide = new Box(50, xCarriageBarWidth + 4, xCarriageBarWidth / 2 + 4);
25 | CsgObject barGroove = new Cylinder(xCarriageBarWidth/2, frontBarRide.XSize + .2, 2);
26 | barGroove = new Translate(barGroove, 0, 0, -barGroove.ZSize / 2);
27 | frontBarRide -= barGroove;
28 | dialGauge = frontBarRide;
29 |
30 | CsgObject backBarRide = frontBarRide.NewMirrorAccrossY();
31 | backBarRide = new Translate(backBarRide, 0, xCarriageSeparation, 0);
32 | dialGauge += backBarRide;
33 |
34 | CsgObject frontSideWall = new Box(frontBarRide.XSize, wallWidth, wallHeight);
35 | frontSideWall = new Align(frontSideWall, Face.Front | Face.Top, frontBarRide, Face.Back | Face.Top, offsetY: -.02); // offset it to ensure good stl geometry
36 | dialGauge += frontSideWall;
37 |
38 | CsgObject backSideWall = new Box(frontBarRide.XSize, wallWidth, wallHeight);
39 | backSideWall = new Align(backSideWall, Face.Back | Face.Top, backBarRide, Face.Front | Face.Top, offsetY: .02); // offset it to ensure good stl geometry
40 | dialGauge += backSideWall;
41 |
42 | // make the plate on the bottom
43 | double distanceAccrossBottom = backSideWall.GetAxisAlignedBoundingBox().MinXYZ.Y - frontSideWall.GetAxisAlignedBoundingBox().MaxXYZ.Y;
44 | CsgObject dialBase = new Box(frontBarRide.XSize, distanceAccrossBottom + .02, wallWidth); // make it bigger so it is manifold
45 | dialBase = new Align(dialBase, Face.Front | Face.Bottom, frontSideWall, Face.Back | Face.Bottom, offsetY: .01);
46 | dialGauge += dialBase;
47 |
48 | // an some side walls for strength
49 | CsgObject leftSideWall = new Box(wallWidth, dialBase.YSize, frontSideWall.ZSize, "#leftsidewall");
50 | leftSideWall = new Align(leftSideWall, Face.Left | Face.Bottom | Face.Front, dialBase, Face.Left | Face.Bottom | Face.Front);
51 | dialGauge += leftSideWall;
52 |
53 | CsgObject rightSideWall = new Box(wallWidth, dialBase.YSize, frontSideWall.ZSize, "#rightsidewall");
54 | rightSideWall = new Align(rightSideWall, Face.Right | Face.Bottom | Face.Front, dialBase, Face.Right | Face.Bottom | Face.Front);
55 | dialGauge += rightSideWall;
56 |
57 | CsgObject dialGaugeHole = new Cylinder(diameterOfDialGaugeBar / 2, dialBase.ZSize + .02, 2);
58 | dialGaugeHole = new SetCenter(dialGaugeHole, dialBase.GetCenter() + new Vector3(0, dialGaugeBarOffsetFromCenter, 0));
59 | dialGauge -= dialGaugeHole;
60 |
61 | CsgObject bridgeSupport = new Box(dialBase.XSize, dialBase.YSize, .5, "#test");
62 | bridgeSupport = new SetCenter(bridgeSupport, dialBase.GetCenter());
63 | bridgeSupport = new Align(bridgeSupport, Face.Top, dialBase, Face.Top);
64 | dialGauge += bridgeSupport;
65 |
66 | return dialGauge;
67 | }
68 |
69 | static void Main()
70 | {
71 | CsgObject dialGauge = DialGaugeMount();
72 | OpenSCadOutput.Save(dialGauge, "DialGaugeMount.scad");
73 | OpenSCadOutput.Save(new Rotate(dialGauge, 0, MathHelper.DegreesToRadians(180)), "DialGaugeMountRotatedForPrint.scad");
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/CommandLineExamples/DialGaugeMount/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "DialGaugeMount": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/CommandLineExamples/PowerSupplyMountingFeet/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using MatterHackers.Csg;
4 | using MatterHackers.Csg.Solids;
5 | using MatterHackers.Csg.Transform;
6 | using MatterHackers.Csg.Processors;
7 | using MatterHackers.VectorMath;
8 |
9 | namespace SimplePartScripting
10 | {
11 | public class PowerSupplyMountingFoot
12 | {
13 | static double wallWidth = 4;
14 | static double footBevelRadius = 2;
15 | static double wallBevelRadius = 2;
16 | static double footMountHoleDiameter = 3.3;
17 | static double powerSupplyHoleDiameter = 4.2;
18 |
19 | static double powerSupplyHoleCenterHeight = 11.5;
20 |
21 | static CsgObject MakeOne()
22 | {
23 | CsgObject total = null;
24 |
25 | Box footBaseBox = new Box(10 + wallWidth, wallWidth * 2 + footMountHoleDiameter, wallWidth);
26 | footBaseBox.BevelEdge(Face.Left | Face.Front, footBevelRadius);
27 | footBaseBox.BevelEdge(Face.Left | Face.Back, footBevelRadius);
28 | CsgObject footBase = footBaseBox;
29 | CsgObject mountHole = new Cylinder(footMountHoleDiameter/2, footBase.ZSize + .2, 2);
30 | mountHole = new Align(mountHole, Face.Left, footBase, Face.Left, wallWidth);
31 | footBase -= mountHole;
32 | total = footBase;
33 |
34 | Box risingWallBox = new Box(wallWidth, footBase.YSize, powerSupplyHoleCenterHeight + powerSupplyHoleDiameter / 2 + wallWidth * 2);
35 | risingWallBox.BevelEdge(Face.Top | Face.Back, wallBevelRadius);
36 | risingWallBox.BevelEdge(Face.Top | Face.Front, wallBevelRadius);
37 | CsgObject risingWall = risingWallBox;
38 | risingWall = new Align(risingWall, Face.Right | Face.Bottom, footBase, Face.Right | Face.Bottom);
39 | CsgObject powerScrewHole = new Cylinder(powerSupplyHoleDiameter / 2, footBase.ZSize + .2, 2);
40 | powerScrewHole = new Align(powerScrewHole, Face.Top | Face.Right, risingWall, Face.Top | Face.Right, offsetX: .02, offsetZ: -wallWidth);
41 | risingWall -= powerScrewHole;
42 |
43 | total += risingWall;
44 |
45 | return total;
46 | }
47 |
48 | static void Main()
49 | {
50 | OpenSCadOutput.Save(MakeOne(), "PowerSupplyMountingFoot.scad");
51 |
52 | double spacing = 5;
53 | CsgObject foot = MakeOne();
54 | CsgObject total = foot;
55 | total += new Translate(foot, foot.XSize + spacing);
56 | total += new Translate(foot, 0, foot.YSize + spacing);
57 | total += new Translate(foot, foot.XSize + spacing, foot.YSize + spacing);
58 | OpenSCadOutput.Save(total, "PowerSupplyMountingFoot 4.scad");
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/CommandLineExamples/PowerSupplyMountingFeet/PowerSupplyMountingFeet.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 |
8 |
9 |
10 | true
11 |
12 |
13 | none
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | all
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CommandLineExamples/PowerSupplyMountingFeet/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "PowerSupplyMountingFeet": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/CommandLineExamples/SpoolBarHolderM90/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using MatterHackers.Csg;
4 | using MatterHackers.Csg.Processors;
5 | using MatterHackers.Csg.Solids;
6 | using MatterHackers.Csg.Transform;
7 | using MatterHackers.VectorMath;
8 |
9 | namespace SimplePartScripting
10 | {
11 | static class SimplePartTester
12 | {
13 | static double wallWidth = 4;
14 | static double mendal90FrameWidth = 6.5;
15 | static double clipReachZUp = 15;
16 | static double clipReachZDown = 20;
17 | static double clipLengthY = 30;
18 | static double rodDiameter = 8.5;
19 | static double attacheHoleDiameter = 3.3;
20 |
21 | static double attachHoleOffsetZ = 10;
22 |
23 | static CsgObject SpoolBarHolderM90()
24 | {
25 | CsgObject total;
26 |
27 | CsgObject centerSupport = new Box(mendal90FrameWidth + wallWidth * 2, clipLengthY, wallWidth);
28 | total = centerSupport;
29 |
30 | CsgObject clipWallLeft = new Box(wallWidth, clipLengthY, clipReachZDown);
31 | clipWallLeft = new Align(clipWallLeft, Face.Left | Face.Top, centerSupport, Face.Left | Face.Top);
32 | CsgObject attachHole = new Cylinder(attacheHoleDiameter/2, wallWidth + .2, 2);
33 | attachHole = new Align(attachHole, Face.Top, centerSupport, Face.Bottom, offsetZ: -attachHoleOffsetZ);
34 | attachHole = new SetCenter(attachHole, clipWallLeft.GetCenter(), onY: false, onZ: false);
35 | clipWallLeft -= attachHole;
36 |
37 | total += clipWallLeft;
38 |
39 | CsgObject clipWallRight = clipWallLeft.NewMirrorAccrossX();
40 | total += clipWallRight;
41 |
42 | Box spoolHoldBox = new Box(wallWidth, rodDiameter * 3, clipReachZUp);
43 | //spoolHoldBox.BevelEdge(Face.Front | Face.Top, rodDiameter/2);
44 | //spoolHoldBox.BevelEdge(Face.Back | Face.Top, rodDiameter / 2);
45 | CsgObject spoolHold = spoolHoldBox;
46 | spoolHold -= new Align(new Cylinder(rodDiameter / 2, wallWidth + 2, 2), Face.Top, spoolHold, Face.Top);
47 | spoolHold -= new Align(new Box(wallWidth + 2, rodDiameter, rodDiameter/2), Face.Top, spoolHold, Face.Top, offsetZ: .1);
48 | total += new Align(spoolHold, Face.Bottom, centerSupport, Face.Bottom);
49 |
50 | total += Round.CreateFillet(spoolHold, Face.Left, centerSupport, Face.Top, 2);
51 | total += Round.CreateFillet(spoolHold, Face.Right, centerSupport, Face.Top, 2);
52 | total -= Round.CreateBevel(centerSupport, Edge.LeftTop, 2);
53 | total -= Round.CreateBevel(centerSupport, Edge.RightTop, 2);
54 |
55 | return total;
56 | }
57 |
58 | static void Main()
59 | {
60 | CsgObject spoolBarHolderM90 = SpoolBarHolderM90();
61 |
62 | OpenSCadOutput.Save(spoolBarHolderM90, "SpoolBarHolderM90.scad");
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/CommandLineExamples/SpoolBarHolderM90/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "SpoolBarHolderM90": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/CommandLineExamples/SpoolBarHolderM90/SpoolBarHolderM90.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 |
8 |
9 |
10 | true
11 |
12 |
13 | none
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | all
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CommandLineExamples/SpoolBearingHolder/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using MatterHackers.Csg;
4 | using MatterHackers.Csg.Solids;
5 | using MatterHackers.Csg.Transform;
6 | using MatterHackers.Csg.Processors;
7 | using MatterHackers.VectorMath;
8 |
9 | namespace SimplePartScripting
10 | {
11 | public abstract class SpoolType
12 | {
13 | public double spoolDiameter;
14 | public double bearingDiameter;
15 | public double bearingHeight;
16 | public double retainingWallHeight;
17 | public double wallWidth;
18 |
19 | public SpoolType()
20 | {
21 | bearingDiameter = 22;
22 | bearingHeight = 7;
23 | retainingWallHeight = bearingHeight;
24 | wallWidth = 4;
25 | }
26 | }
27 |
28 | public class EsunSmallSpool : SpoolType
29 | {
30 | public EsunSmallSpool()
31 | {
32 | spoolDiameter = 32;
33 | }
34 | }
35 |
36 | public class PackingBagSpool : SpoolType
37 | {
38 | public PackingBagSpool()
39 | {
40 | retainingWallHeight = bearingHeight + 10;
41 | wallWidth = 6;
42 | spoolDiameter = 75;
43 | }
44 | }
45 |
46 | static class CreateBearingHolder
47 | {
48 | //static double spoolDiameter = 40;
49 |
50 | static CsgObject SpoolBearingHolder(SpoolType spoolType)
51 | {
52 | // CSG object is a Constructive Solid Geometry Object (a basic part in our system for doing boolean operations).
53 | CsgObject spoolBearingHolder; // the csg object we will use as the master part.
54 |
55 | spoolBearingHolder = new Cylinder(spoolType.spoolDiameter / 2 + 1, spoolType.spoolDiameter / 2 - 1, spoolType.retainingWallHeight + spoolType.wallWidth);
56 |
57 | CsgObject insideHole = new Cylinder(spoolType.spoolDiameter / 2 - spoolType.wallWidth, spoolType.retainingWallHeight);
58 | insideHole = new Align(insideHole, Face.Top, spoolBearingHolder, Face.Top, offsetZ: .02);
59 | spoolBearingHolder -= insideHole;
60 |
61 | CsgObject spoolHoldLip = new Cylinder(spoolType.spoolDiameter / 2 + spoolType.wallWidth, spoolType.wallWidth);
62 | spoolHoldLip = new Align(spoolHoldLip, Face.Bottom, spoolBearingHolder, Face.Bottom);
63 | spoolBearingHolder += spoolHoldLip;
64 |
65 | CsgObject bearingHolder = new Cylinder((spoolType.bearingDiameter + spoolType.wallWidth) / 2, spoolType.bearingHeight + spoolType.wallWidth);
66 | bearingHolder = new Align(bearingHolder, Face.Bottom, spoolBearingHolder, Face.Bottom);
67 | spoolBearingHolder += bearingHolder;
68 |
69 | CsgObject bearingHole = new Cylinder(spoolType.bearingDiameter / 2, spoolType.bearingHeight);
70 | bearingHole = new Align(bearingHole, Face.Bottom, spoolBearingHolder, Face.Bottom, offsetZ: -.02);
71 | spoolBearingHolder -= bearingHole;
72 |
73 | CsgObject revolution = new RotateExtrude(new double[] { 0, -.02, spoolType.wallWidth, 0, 0, spoolType.wallWidth + .02 }, spoolType.bearingDiameter / 2 - spoolType.wallWidth);
74 | revolution = new Align(revolution, Face.Top, bearingHolder, Face.Top);
75 |
76 | spoolBearingHolder -= revolution;
77 |
78 | CsgObject rodHole = new Cylinder(spoolType.bearingDiameter / 2 - spoolType.wallWidth, spoolBearingHolder.ZSize + 2);
79 | rodHole = new Align(rodHole, Face.Top, spoolBearingHolder, Face.Top, offsetZ: .02);
80 | spoolBearingHolder -= rodHole;
81 |
82 | return spoolBearingHolder;
83 | }
84 |
85 | static void Main()
86 | {
87 | OpenSCadOutput.Save(SpoolBearingHolder(new EsunSmallSpool()), "SpoolBearingHolder.scad");
88 | OpenSCadOutput.Save(SpoolBearingHolder(new PackingBagSpool()), "PackingBagsBearingHolder.scad");
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/CommandLineExamples/SpoolBearingHolder/SpoolBearingHolder.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 |
8 |
9 |
10 | true
11 |
12 |
13 | none
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | all
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CommandLineExamples/StepArmForHobbit/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using MatterHackers.Csg;
4 | using MatterHackers.Csg.Solids;
5 | using MatterHackers.Csg.Transform;
6 | using MatterHackers.Csg.Processors;
7 | using MatterHackers.VectorMath;
8 |
9 | namespace SimplePartScripting
10 | {
11 | static class SimplePartTester
12 | {
13 | static double wallWidth = 4;
14 |
15 | static double armLength = 40;
16 | static double pivotHeight = 11;
17 | static double pivotHoleRadius = 3.3;
18 | static double pivotRingRadius = pivotHoleRadius + wallWidth;
19 |
20 | static CsgObject StepArm()
21 | {
22 | CsgObject totalMount; // the csg object we will use as the master part.
23 |
24 | CsgObject pivotHole = new Cylinder(pivotHoleRadius / 2, pivotHeight + .1 ,2);
25 |
26 | CsgObject pivotMount = new Cylinder(pivotRingRadius / 2, pivotHeight, 2);
27 | pivotMount = new Align(pivotMount, Face.Bottom, pivotHole, Face.Bottom, offsetZ: .02);
28 | totalMount = pivotMount;
29 |
30 | CsgObject holdArm = new Box(armLength, pivotRingRadius, wallWidth);
31 | holdArm = new Align(holdArm, Face.Left | Face.Front | Face.Bottom, pivotMount, Face.Left | Face.Front | Face.Bottom, offsetX: pivotRingRadius / 2);
32 | totalMount += holdArm;
33 |
34 | CsgObject bracingWall = new Box(wallWidth, wallWidth, pivotMount.ZSize - wallWidth);
35 | bracingWall = new SetCenter(bracingWall, holdArm.GetCenter());
36 | bracingWall = new Align(bracingWall, Face.Right | Face.Top, pivotMount, Face.Right | Face.Top);
37 | totalMount += bracingWall;
38 |
39 | CsgObject bracingArm = new Box(armLength, wallWidth, wallWidth);
40 | bracingArm = new SetCenter(bracingArm, holdArm.GetCenter());
41 | bracingArm = new Align(bracingArm, Face.Bottom | Face.Left, holdArm, Face.Top | Face.Left, offsetZ: -.1);
42 | totalMount += bracingArm;
43 |
44 | totalMount += Round.CreateFillet(bracingWall, Face.Right, bracingArm, Face.Top, 3);
45 | //totalMount += Round.CreateFillet(bracingArm, Face.Right, holdArm, Face.Top, wallWidth);
46 |
47 | double toothSelectorSize = 4;
48 | double diagonalSize = Math.Sqrt(toothSelectorSize * toothSelectorSize / 2);
49 | CsgObject toothSelectorBack = new Box(diagonalSize*2, diagonalSize*2, wallWidth * 2);
50 | toothSelectorBack = new Align(toothSelectorBack, Face.Right | Face.Front | Face.Bottom, totalMount, Face.Right | Face.Front | Face.Bottom);
51 | totalMount += toothSelectorBack;
52 |
53 | CsgObject toothSelector = new Box(toothSelectorSize, toothSelectorSize, wallWidth * 2);
54 | toothSelector = new Rotate(toothSelector, 0, 0, MathHelper.Tau / 8);
55 | toothSelector = new Align(toothSelector, Face.Right | Face.Front | Face.Bottom, totalMount, Face.Right | Face.Front | Face.Bottom, offsetY: -diagonalSize);
56 | totalMount += toothSelector;
57 |
58 |
59 | totalMount -= pivotHole;
60 |
61 | return totalMount;
62 | }
63 |
64 | static void Main()
65 | {
66 | OpenSCadOutput.Save(StepArm(), "hobbit step arm.scad");
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/CommandLineExamples/StepArmForHobbit/StepArmForHobbit.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 |
8 |
9 |
10 | true
11 |
12 |
13 | none
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | all
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CommandLineExamples/TPBinoculars/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using MatterHackers.Csg;
4 | using MatterHackers.Csg.Solids;
5 | using MatterHackers.Csg.Transform;
6 | using MatterHackers.Csg.Operations;
7 | using MatterHackers.Csg.Processors;
8 | using MatterHackers.VectorMath;
9 |
10 | namespace SimplePartScripting
11 | {
12 | static class SimplePartTester
13 | {
14 | static double centerXSize = 15;
15 |
16 | static CsgObject TPBinoculars()
17 | {
18 | CsgObject total;
19 |
20 | Box centerBarHoldBox = new Box(centerXSize + 10, 30, 10);
21 | centerBarHoldBox.BevelFace(Face.Front, 3);
22 | CsgObject centerBarHold = centerBarHoldBox;
23 | CsgObject leftTube = new Align(LeftTube(), Face.Front, centerBarHold, Face.Front, 0, 4);
24 | CsgObject rightTube = new Align(RightTube(), Face.Front, centerBarHold, Face.Front, 0, 4);
25 | centerBarHold -= leftTube;
26 | centerBarHold -= rightTube;
27 | total = centerBarHold;
28 |
29 | Box centerBarBox = new Box(centerXSize + 5, 30, 10);
30 | centerBarBox.BevelFace(Face.Back, 3);
31 | CsgObject centerBar = centerBarBox;
32 | centerBar -= new Align(LeftTube(false), Face.Front, centerBar, Face.Front, 0, -.1);
33 | centerBar -= new Align(RightTube(false), Face.Front, centerBar, Face.Front, 0, -.1);
34 | centerBar = new Align(centerBar, Face.Front, centerBarHold, Face.Back, offsetY: -1);
35 | total += centerBar;
36 |
37 | CsgObject noseSpace = new Cylinder(centerXSize / 2 + .5, centerXSize / 2 - 2, 2);
38 | noseSpace = new Align(noseSpace, Face.Front, centerBarHold, Face.Front, 0, -noseSpace.YSize/2);
39 | total -= noseSpace;
40 |
41 | CsgObject spinner = new Cylinder(6, 10, 2);
42 | CsgObject spinnerRidge = new Cylinder(.5, spinner.YSize - 2 , 2);
43 | spinnerRidge = new Translate(spinnerRidge, spinner.XSize / 2);
44 | for (int i = 0; i <= 10; i++)
45 | {
46 | spinner += new Rotate(spinnerRidge, 0, MathHelper.DegreesToRadians(-18 * i));
47 | }
48 |
49 | spinner = new Translate(spinner, 0, 25, 3);
50 | CsgObject spinnerGap = new Box(13, spinner.YSize + 2, 1);
51 | spinnerGap = new Align(spinnerGap, Face.Top, centerBar, Face.Top, offsetZ: .1);
52 | spinnerGap = new Align(spinnerGap, Face.Front, spinner, Face.Front, offsetY: -1);
53 | total -= spinnerGap;
54 | total += spinner;
55 |
56 | total += new Translate(new Sphere(2), -3, 5, 4);
57 | total += new Translate(new Sphere(2), 3, 5, 4);
58 | total += new Translate(new Sphere(4), 0, 37, 4);
59 | //total -= new Translate(new Sphere(4), 1, 37, 9);
60 | total += new Translate(new Sphere(4), 0, -3, 5);
61 | //total -= new Translate(new Sphere(4), -1, -3, 11);
62 |
63 | total -= new Translate(new Sphere(4), 2, 12, 6);
64 | total -= new Translate(new Sphere(4), 1, 12, 6);
65 | total -= new Translate(new Sphere(4), 0, 12, 6);
66 | total -= new Translate(new Sphere(4), -1, 12, 6);
67 | total -= new Translate(new Sphere(4), -2, 12, 6);
68 | total += new Translate(new Sphere(4), 0, 12, 1);
69 |
70 | total += new Translate(leftTube, name: "%see only");
71 | total += new Translate(rightTube, name: "%see only");
72 |
73 | return total;
74 | }
75 |
76 | static CsgObject LeftTube(bool hollow = true)
77 | {
78 | CsgObject tPTube = new Cylinder(40 / 2, 105, 2);
79 | if (hollow)
80 | {
81 | tPTube -= new Cylinder(40 / 2 - 1, 106, 2);
82 | }
83 | tPTube = new Translate(tPTube, -(tPTube.XSize / 2 + centerXSize / 2));
84 | return tPTube;
85 | }
86 |
87 | static CsgObject RightTube(bool hollow = true)
88 | {
89 | CsgObject tPTube = LeftTube(hollow);
90 | tPTube = new Translate(tPTube, (tPTube.XSize + centerXSize));
91 | return tPTube;
92 | }
93 |
94 | static void Main()
95 | {
96 | Matrix4X4 rotateAboutZ = Matrix4X4.CreateRotationZ(MathHelper.DegreesToRadians(2));
97 |
98 | CsgObject tPBinoculars = TPBinoculars();
99 |
100 | OpenSCadOutput.Save(tPBinoculars, "TPBinoculars.scad");
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/CommandLineExamples/TPBinoculars/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "TPBinoculars": {
4 | "commandName": "Project"
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/CommandLineExamples/TPBinoculars/TPBinoculars.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 |
8 |
9 |
10 | true
11 |
12 |
13 | none
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | all
26 |
27 |
28 |
--------------------------------------------------------------------------------
/CommandLineExamples/TrainConnector/MatterCad.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Csg; // our constructive solid geometry base classes
2 | using MatterHackers.Csg.Processors;
3 | using MatterHackers.Csg.Solids;
4 |
5 | namespace SimplePartScripting
6 | {
7 | static class SimplePartTester
8 | {
9 | static CsgObject TrackConnecor()
10 | {
11 | // CsgObject is our base class for all constructive solid geometry primitives
12 | CsgObject total;
13 |
14 | CsgObject extrude = new LinearExtrude(new double[] { 0, 10, 10, 10, 10, 0, 0, 0}, 10,new Alignment(), 10, "test" );
15 | //// we create a box object and name it 'link'
16 | //CsgObject bar = new Box(20, 5.8, 12, "link");
17 |
18 | //// we set it's center to the center of the coordinate system
19 | //bar = new SetCenter(bar, Vector3.Zero);
20 | //// and we make the total = the only object we have at this time
21 | //total = bar;
22 | total = extrude;
23 |
24 | //// now we make a cyliner for the side
25 | //CsgObject leftHold = new Cylinder(11.7 / 2, 12, Alignment.z);
26 | //// position it where we want it
27 | //leftHold = new SetCenter(leftHold, bar.GetCenter() + new Vector3(12, 0, 0));
28 | //// and make another one on the other side by mirroring
29 | //CsgObject rightHold = leftHold.NewMirrorAccrossX();
30 | //// this is the way we actuall decide what boolean operation to put them together with
31 | //total += leftHold;
32 | //total += rightHold;
33 |
34 | return total; // and pass it back to the caller
35 | }
36 |
37 | static void Main()
38 | {
39 | // an internal function to save as an .scad file
40 | OpenSCadOutput.Save(TrackConnecor(), "TrackConnector.scad");
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/CommandLineExamples/TrainConnector/TrainConnector.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net6.0
4 | Exe
5 | MatterHackers.MatterCad
6 | MatterHackers.MatterCAD
7 |
8 |
9 |
10 | true
11 |
12 |
13 | none
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | all
26 |
27 |
28 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/CodeHelper.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.CSharp;
2 | using System.CodeDom.Compiler;
3 | using System.Collections.Generic;
4 |
5 | namespace DynCode
6 | {
7 | public class CodeHelper
8 | {
9 | public static object HelperFunction(string classCode, string mainClass, object[] requiredAssemblies)
10 | {
11 | CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary { { "CompilerVersion", "v4.0" } });
12 |
13 | CompilerParameters parameters = new CompilerParameters
14 | {
15 | GenerateExecutable = false, // Create a dll
16 | GenerateInMemory = true, // Create it in memory
17 | WarningLevel = 3, // Default warning level
18 | CompilerOptions = "/optimize", // Optimize code
19 | TreatWarningsAsErrors = false // Better be false to avoid break in warnings
20 | };
21 |
22 | //----------------
23 | // Add basic referenced assemblies
24 | parameters.ReferencedAssemblies.Add("system.dll");
25 | parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll");
26 | parameters.ReferencedAssemblies.Add("System.Core.dll");
27 | parameters.ReferencedAssemblies.Add("AGG.dll");
28 |
29 | parameters.ReferencedAssemblies.Add("MatterHackers.Agg.UI.dll");
30 | parameters.ReferencedAssemblies.Add("MatterHackers.PolygonMesh.dll");
31 | parameters.ReferencedAssemblies.Add("MatterHackers.VectorMath.dll");
32 | parameters.ReferencedAssemblies.Add("MatterHackers.Csg.dll");
33 | parameters.ReferencedAssemblies.Add("MatterHackers.RenderOpenGl.dll");
34 | //using MatterHackers.PolygonMesh;
35 | //using MatterHackers.VectorMath;
36 | //using MatterHackers.Csg.Operations;
37 | //using MatterHackers.Csg.Solids;
38 | //using MatterHackers.RenderOpenGl;
39 | //using MatterHackers.Agg;
40 |
41 | //----------------
42 | // Add all extra assemblies required
43 | foreach (var extraAsm in requiredAssemblies)
44 | {
45 | parameters.ReferencedAssemblies.Add(extraAsm as string);
46 | }
47 |
48 | //--------------------
49 | // Try to compile the code received
50 | CompilerResults results = provider.CompileAssemblyFromSource(parameters, classCode);
51 |
52 | //--------------------
53 | // If the compilation returned error, then return the CompilerErrorCollection class with the errors to the caller
54 | if (results.Errors.Count != 0)
55 | {
56 | return results.Errors;
57 | }
58 |
59 | //--------------------
60 | // Return the created class instance to caller
61 | return results.CompiledAssembly.CreateInstance(mainClass);
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/DynCode.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {61E4F649-AC77-41C7-8D65-D2AF5FFC9D63}
8 | Library
9 | Properties
10 | DynCode
11 | DynCode
12 | v4.8
13 | 512
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | Form
54 |
55 |
56 | Form1.cs
57 |
58 |
59 |
60 |
61 | Form1.cs
62 |
63 |
64 | ResXFileCodeGenerator
65 | Resources.Designer.cs
66 | Designer
67 |
68 |
69 | True
70 | Resources.resx
71 | True
72 |
73 |
74 | SettingsSingleFileGenerator
75 | Settings.Designer.cs
76 |
77 |
78 | True
79 | Settings.settings
80 | True
81 |
82 |
83 |
84 |
85 |
86 |
87 |
94 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/DynCode.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynCode", "DynCode.csproj", "{61E4F649-AC77-41C7-8D65-D2AF5FFC9D63}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {61E4F649-AC77-41C7-8D65-D2AF5FFC9D63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {61E4F649-AC77-41C7-8D65-D2AF5FFC9D63}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {61E4F649-AC77-41C7-8D65-D2AF5FFC9D63}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {61E4F649-AC77-41C7-8D65-D2AF5FFC9D63}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.CodeDom.Compiler;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Windows.Forms;
6 |
7 | namespace DynCode
8 | {
9 | public partial class Form1 : Form
10 | {
11 | public Form1()
12 | {
13 | InitializeComponent();
14 | }
15 |
16 | private void btnRunCode_Click(object sender, EventArgs e)
17 | {
18 | Execute(txtCodeToRun.Text);
19 | }
20 |
21 | private void Execute(string code)
22 | {
23 | StringBuilder sb = new StringBuilder();
24 |
25 | //-----------------
26 | // Create the class as usual
27 | sb.AppendLine("using System;");
28 | sb.AppendLine("using System.Windows.Forms;");
29 | sb.AppendLine("using System.Collections.Generic;");
30 | sb.AppendLine();
31 | sb.AppendLine("namespace CountryList");
32 | sb.AppendLine("{");
33 |
34 | sb.AppendLine(" public class SelectCountries");
35 | sb.AppendLine(" {");
36 |
37 | // My pre-defined class named FilterCountries that receive the sourceListBox
38 | sb.AppendLine(" public List FilterCountries(ListBox countryList)");
39 | sb.AppendLine(" {");
40 | sb.AppendLine(code);
41 | sb.AppendLine(" }");
42 | sb.AppendLine(" }");
43 | sb.AppendLine("}");
44 |
45 | //-----------------
46 | // The finished code
47 | string classCode = sb.ToString();
48 |
49 | //-----------------
50 | // Dont need any extra assemblies
51 |
52 | dynamic classRef;
53 | try
54 | {
55 | txtErrors.Clear();
56 |
57 | //------------
58 | // Pass the class code, the namespace of the class and the list of extra assemblies needed
59 | classRef = CodeHelper.HelperFunction(classCode, "CountryList.SelectCountries", new object[] { });
60 |
61 | //-------------------
62 | // If the compilation process returned an error, then show to the user all errors
63 | if (classRef is CompilerErrorCollection)
64 | {
65 | StringBuilder sberror = new StringBuilder();
66 |
67 | foreach (CompilerError error in (CompilerErrorCollection)classRef)
68 | {
69 | sberror.AppendLine(string.Format("{0}:{1} {2} {3}", error.Line, error.Column, error.ErrorNumber, error.ErrorText));
70 | }
71 |
72 | txtErrors.Text = sberror.ToString();
73 |
74 | return;
75 | }
76 | }
77 | catch (Exception ex)
78 | {
79 | // If something very bad happened then throw it
80 | MessageBox.Show(ex.Message);
81 | throw;
82 | }
83 |
84 | //-------------
85 | // Finally call the class to filter the countries with the specific routine provided
86 | List targetValues = classRef.FilterCountries(lstSource);
87 |
88 | //-------------
89 | // Move the result to the target listbox
90 | lstTarget.Items.Clear();
91 | lstTarget.Items.AddRange(targetValues.ToArray());
92 | }
93 | }
94 | }
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | List<string> result = new List<string>();
122 |
123 | foreach (string country in countryList.Items)
124 | {
125 | if (country.StartsWith("C", StringComparison.InvariantCultureIgnoreCase))
126 | {
127 | result.Add(country);
128 | }
129 | }
130 |
131 | return result;
132 |
133 |
134 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Aleksei Prokopov
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 | namespace DynCode
5 | {
6 | static class Program
7 | {
8 | ///
9 | /// The main entry point for the application.
10 | ///
11 | [STAThread]
12 | static void Main()
13 | {
14 | Application.EnableVisualStyles();
15 | Application.SetCompatibleTextRenderingDefault(false);
16 | Application.Run(new Form1());
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WindowsFormsApplication1")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WindowsFormsApplication1")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("b82c62c2-b4b3-4546-a42f-9f7aedff69b9")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DynCode.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DynCode.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DynCode.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/DinamiclyExecuteCode/Screenshot.png
--------------------------------------------------------------------------------
/DinamiclyExecuteCode/readme.md:
--------------------------------------------------------------------------------
1 |
2 | Executing C# code from Form application
3 |
4 | 
--------------------------------------------------------------------------------
/Examples/LinearExtrude.cs:
--------------------------------------------------------------------------------
1 | var rootUnion = new MatterHackers.Csg.Operations.Union("root");
2 | rootUnion.Add(new LinearExtrude(new double[] {0, 10, 10, 10, 0, 0}, 10,new Alignment(), 0 ));
3 | return rootUnion;
4 |
--------------------------------------------------------------------------------
/Examples/Rotate.cs:
--------------------------------------------------------------------------------
1 | var rootUnion = new MatterHackers.Csg.Operations.Union("root");
2 |
3 |
4 | for (int i = 0; i != 10; i++)
5 |
6 | {
7 | rootUnion.Add(new Rotate(new BoxPrimitive(18, i, 14), 10 * i, 10, 10));
8 | }
9 |
10 |
11 | return rootUnion;
12 |
13 |
--------------------------------------------------------------------------------
/Examples/snippet.cs:
--------------------------------------------------------------------------------
1 | var rootUnion = new MatterHackers.Csg.Operations.Union("root");
2 |
3 |
4 |
5 | rootUnion.Add(new Translate(new Cylinder(10, 40), 5, 10, 5));
6 |
7 |
8 |
9 | rootUnion.Add(new BoxPrimitive(8, 20, 10));
10 |
11 |
12 |
13 | for(int i=0;i!=10;i++)
14 |
15 | rootUnion.Add(new Translate(new BoxPrimitive(18, i, 14),10*i,10,10));
16 |
17 | return rootUnion;
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/7CVkr2ch1PloVxbPqSkQtyv1TfDuILg19h8WlTspCtlxPAt4c3GhPoJoh0Ru.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/7CVkr2ch1PloVxbPqSkQtyv1TfDuILg19h8WlTspCtlxPAt4c3GhPoJoh0Ru.png
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/AAWq6WJ0tMYkC_MlRyt1V6VicoC-fUOi_MRZe3QcifHrVlSxqigtER-W1oEi.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/AAWq6WJ0tMYkC_MlRyt1V6VicoC-fUOi_MRZe3QcifHrVlSxqigtER-W1oEi.png
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/DAIz90qRgmQZjCftT5ejMJYsvKBV4nh4FFUJPCXtyJ5cBOe1L6h5KYNxT16U.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/DAIz90qRgmQZjCftT5ejMJYsvKBV4nh4FFUJPCXtyJ5cBOe1L6h5KYNxT16U.png
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/ZUuuDWD2Z6h2vt3s8qyj3t05ZCkOp3_YsJAQQ6A8C3jV-9jPQ0LJi2Hc-AMv.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/ZUuuDWD2Z6h2vt3s8qyj3t05ZCkOp3_YsJAQQ6A8C3jV-9jPQ0LJi2Hc-AMv.png
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/a:
--------------------------------------------------------------------------------
1 | (function(){var s = {};(function(){var c=/#|$/,f=function(d){var g=d.search(c),a;a:{for(a=0;0<=(a=d.indexOf("fmt",a))&&aa)return null;b=d.indexOf("&",a);if(0>b||b>g)b=g;a+=4;return decodeURIComponent(d.substr(a,b-a).replace(/\+/g," "))};var k=function(d,g,a){for(var b=a.length+1,n=function(){--b;if(0>=b){var a;(a=d.GooglebQhCsO)||(a={});var e=a[g];e&&(delete a[g],(a=e[0])&&a.call&&a())}},l=0;l 0) {
50 | var cookie_data = response;
51 | var expires = cookie_data.match(/&duration=([0-9]+)/);
52 |
53 | if (expires != null) {
54 | var now = new Date();
55 | if (request_mode == 'track') {
56 | var time = now.getTime();
57 | var expireTime = time + parseInt(expires[1]) * 1000;
58 | now.setTime(expireTime);
59 | }
60 | else {
61 | expireTime = cookie_data.match(/&expire_time=([0-9]+)/);
62 | now.setTime(parseInt(expireTime[1]) * 1000);
63 | }
64 |
65 | document.cookie = "easy_affiliate=" + cookie_data + "; expires=" + now.toGMTString() + "; path=/";
66 | }
67 | }
68 | else if (request_mode == 'mark') {
69 | //alert( response );
70 | }
71 | }
72 |
73 | function getURLParameter(name) {
74 | return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)', 'i').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null
75 | }
76 |
77 | function getURLHashParameter(name) {
78 | return decodeURIComponent((new RegExp('[#]' + name + '=' + '([^&;]+?)(&|#|;|$)', 'i').exec(location.hash) || [, ""])[1].replace(/\+/g, '%20')) || null
79 | }
80 |
81 | function getTrackingParameter() {
82 | var tracking_parameter = {};
83 | tracking_parameter.get = {};
84 | tracking_parameter.hash = {};
85 |
86 | if (getURLParameter('aff') != null)
87 | tracking_parameter.get.aff = getURLParameter('aff');
88 | if (getURLParameter('ref') != null)
89 | tracking_parameter.get.ref = getURLParameter('ref');
90 |
91 | if (getURLHashParameter('aff') != null)
92 | tracking_parameter.hash.aff = getURLHashParameter('aff');
93 | if (getURLHashParameter('ref') != null)
94 | tracking_parameter.hash.ref = getURLHashParameter('ref');
95 |
96 | return tracking_parameter;
97 | }
98 |
99 | affiliately.startTracking = function(id_affiliatly, aff_override) {
100 | if (!aff_override) aff_override = null;
101 |
102 | request_mode = 'track';
103 | var data = affiliately.getCookie('easy_affiliate');
104 | var tracking_parameter = getTrackingParameter();
105 |
106 | if (aff_override != null){
107 | console.log('Affiliate override: ' + aff_override);
108 | tracking_parameter.get.aff = aff_override;
109 | }
110 |
111 | if ((isEmpty(tracking_parameter.get) == false || isEmpty(tracking_parameter.hash) == false) && data.length == 0) // no cookie at all
112 | {
113 | var post_data = 'mode=track-v2&id_affiliatly=' + id_affiliatly + '&tracking_parameter=' + JSON.stringify(tracking_parameter) + '&referer=' + document.referrer;
114 | console.log('Request: ' + post_data)
115 | if (getURLParameter('qr') != null)
116 | post_data += '&qr=1';
117 |
118 | callOtherDomain(post_data);
119 | }
120 | else if (data.length > 0) // check the cookie
121 | {
122 | var cookie_data = data.split('&');
123 | cookie_ip = cookie_data[0].split('=');
124 | cookie_ip = cookie_ip[1];
125 |
126 | if ((isEmpty(tracking_parameter.get) == false || isEmpty(tracking_parameter.hash) == false))
127 | data += '&store_visit=1';
128 |
129 | if (cookie_ip.length > 0) {
130 | request_mode = 'update';
131 | post_data = 'mode=cookie_update&id_affiliatly=' + id_affiliatly + '&' + data;
132 | callOtherDomain(post_data);
133 | }
134 | }
135 | };
136 |
137 | if (typeof String.prototype.trim !== 'function') {
138 | String.prototype.trim = function () {
139 | return this.replace(/^\s+|\s+$/g, '');
140 | };
141 | }
142 |
143 | affiliately.getCookie = function (cname) {
144 | var name = cname + "=";
145 | var ca = document.cookie.split(';');
146 | for (var i = 0; i < ca.length; i++) {
147 | var c = ca[i].trim();
148 | if (c.indexOf(name) == 0)
149 | return c.substring(name.length, c.length);
150 | }
151 |
152 | return "";
153 | };
154 |
155 | function isEmpty(obj) {
156 | for (var prop in obj) {
157 | if (obj.hasOwnProperty(prop))
158 | return false;
159 | }
160 |
161 | return true;
162 |
163 | }
164 |
165 | }(window.affiliately = window.affiliately || {}, jQuery));
166 |
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/f_AKhimVj4TU5JGlBQ4l9MQCyAb9i_iIAK1RXgK61Mbf_oigBZVKzvnrgrw9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/f_AKhimVj4TU5JGlBQ4l9MQCyAb9i_iIAK1RXgK61Mbf_oigBZVKzvnrgrw9.png
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/mh-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/mh-icon.png
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/mh-logo-themed-pixelfit.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/mh-logo-white.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out.gif
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out.txt:
--------------------------------------------------------------------------------
1 | OK! Synced cookie [adrl], demand partner's user ID [MzBlYzE0OWYzMmIxODAxYjA0MDZiOTEzMzQwMGViYWM]
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_002.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_002.gif
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_002.html:
--------------------------------------------------------------------------------
1 |
2 | Store Cookieless RTB Data
3 |
4 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_003.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_003.gif
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_004.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_004.gif
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_005.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_005.gif
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_006.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_006.gif
--------------------------------------------------------------------------------
/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_007.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCAD - Design Your 3D Parts In C# MatterHackers_files/out_007.gif
--------------------------------------------------------------------------------
/MatterCadGui/.vs/MatterCadGui/v14/.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCadGui/.vs/MatterCadGui/v14/.suo
--------------------------------------------------------------------------------
/MatterCadGui/CsgEdtors/CsgEditorBase.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using MatterHackers.Csg;
6 | using MatterHackers.Csg.Operations;
7 | using MatterHackers.Csg.Solids;
8 | using MatterHackers.Csg.Processors;
9 | using MatterHackers.Csg.Transform;
10 | using MatterHackers.Agg.UI;
11 | using System.Diagnostics;
12 |
13 | namespace MatterHackers.MatterCadGui.CsgEditors
14 | {
15 | public static class CsgEditorBase
16 | {
17 | public static GuiWidget CreateEditorForCsg(CsgObject csgObject)
18 | {
19 | if (csgObject.GetType() == typeof(BoxPrimitive))
20 | {
21 | return new CsgEditorBox((BoxPrimitive)csgObject);
22 | }
23 | else if (csgObject.GetType() == typeof(Union))
24 | {
25 | return new CsgEditorUnion((Union)csgObject);
26 | }
27 | else if (csgObject.GetType() == typeof(Translate))
28 | {
29 | return new CsgEditorTranslate((Translate)csgObject);
30 | }
31 | else
32 | {
33 | Debug.WriteLine(csgObject.GetType());
34 | return new CsgEditorBox((BoxPrimitive)csgObject);
35 | // throw new NotImplementedException();
36 | }
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/MatterCadGui/CsgEdtors/CsgEditorBox.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using MatterHackers.Csg;
6 | using MatterHackers.Csg.Solids;
7 | using MatterHackers.Agg.UI;
8 | using MatterHackers.VectorMath;
9 |
10 | namespace MatterHackers.MatterCadGui.CsgEditors
11 | {
12 | public class CsgEditorBox : FlowLayoutWidget
13 | {
14 | BoxPrimitive target;
15 | public CsgEditorBox(BoxPrimitive target)
16 | {
17 | this.target = target;
18 |
19 | AddChild(new TextWidget("Box"));
20 | AddVectorEdit(target, 0);
21 | AddVectorEdit(target, 1);
22 | AddVectorEdit(target, 2);
23 | }
24 |
25 | private void AddVectorEdit(BoxPrimitive target, int index)
26 | {
27 | NumberEdit editControl = new NumberEdit(target.Size[index], pixelWidth: 35, allowDecimals: true)
28 | {
29 | TabIndex = index
30 | };
31 | editControl.InternalNumberEdit.TextChanged += (sender, e) =>
32 | {
33 | Vector3 newSize = target.Size;
34 | newSize[index] = editControl.Value;
35 | target.Size = newSize;
36 | };
37 | AddChild(editControl);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MatterCadGui/CsgEdtors/CsgEditorTranslate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using MatterHackers.Csg;
6 | using MatterHackers.Csg.Solids;
7 | using MatterHackers.Csg.Transform;
8 | using MatterHackers.Agg.UI;
9 | using MatterHackers.VectorMath;
10 |
11 | namespace MatterHackers.MatterCadGui.CsgEditors
12 | {
13 | public class CsgEditorTranslate : FlowLayoutWidget
14 | {
15 | Translate target;
16 | public CsgEditorTranslate(Translate target)
17 | : base(FlowDirection.TopToBottom)
18 | {
19 | this.target = target;
20 |
21 | FlowLayoutWidget row = new FlowLayoutWidget();
22 | row.AddChild(new TextWidget("Translate"));
23 | AddVectorEdit(row, target, 0);
24 | AddVectorEdit(row, target, 1);
25 | AddVectorEdit(row, target, 2);
26 | AddChild(row);
27 |
28 | row = new FlowLayoutWidget();
29 | row.AddChild(new GuiWidget(10, 3));
30 | row.AddChild(CsgEditorBase.CreateEditorForCsg(target.ObjectToTransform));
31 | AddChild(row);
32 | }
33 |
34 | private void AddVectorEdit(GuiWidget parent, Translate target, int index)
35 | {
36 | NumberEdit editControl = new NumberEdit(target.Size[index], pixelWidth: 35, allowNegatives: true, allowDecimals: true);
37 | editControl.TabIndex = index;
38 | editControl.InternalNumberEdit.TextChanged += (sender, e) =>
39 | {
40 | Vector3 newSize = target.Translation;
41 | newSize[index] = editControl.Value;
42 | target.Translation = newSize;
43 | };
44 | parent.AddChild(editControl);
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/MatterCadGui/CsgEdtors/CsgEditorUnion.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Csg;
2 | using MatterHackers.Csg.Operations;
3 | using MatterHackers.Agg.UI;
4 |
5 | namespace MatterHackers.MatterCadGui.CsgEditors
6 | {
7 | public class CsgEditorUnion : FlowLayoutWidget
8 | {
9 | Union target;
10 | public CsgEditorUnion(Union target)
11 | : base(FlowDirection.TopToBottom)
12 | {
13 | this.target = target;
14 |
15 | AddChild(new TextWidget("Union"));
16 | foreach (CsgObject part in target.AllObjects)
17 | {
18 | FlowLayoutWidget row = new FlowLayoutWidget();
19 | row.AddChild(new GuiWidget(10, 2));
20 | row.AddChild(CsgEditorBase.CreateEditorForCsg(part));
21 | AddChild(row);
22 | }
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/MatterCadGui/Logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCadGui/Logo.png
--------------------------------------------------------------------------------
/MatterCadGui/MatterCadGui.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Agg.UI;
2 | using System;
3 |
4 | namespace MatterHackers.MatterCad
5 | {
6 | public class MatterCadGui : SystemWindow
7 | {
8 | MatterCadGuiWidget matterCadGuiWidget;
9 |
10 | public MatterCadGui(bool renderRayTrace) : base(800, 600)
11 | {
12 | if (renderRayTrace)
13 | {
14 | matterCadGuiWidget = new MatterCadGuiWidget();
15 | AddChild(matterCadGuiWidget);
16 | matterCadGuiWidget.AnchorAll();
17 | AnchorAll();
18 | }
19 | }
20 |
21 | [STAThread]
22 | public static void Main(string[] args)
23 | {
24 | MatterCadGui cadWindow = new MatterCadGui(true)
25 | {
26 | UseOpenGL = true,
27 | Title = "MatterCADGui"
28 | };
29 | cadWindow.ShowAsSystemWindow();
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/MatterCadGui/MatterCadGui.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 8.0.50727
7 | 2.0
8 | {A20459AD-3006-402C-952C-F4A9D9969A87}
9 | WinExe
10 | Properties
11 | MatterHackers.MatterCadGui
12 | MatterHackers.MatterCADGui
13 | False
14 | False
15 | False
16 | Auto
17 | 4194304
18 | AnyCPU
19 | 4096
20 | false
21 |
22 |
23 |
24 |
25 | 2.0
26 | false
27 | v4.8
28 |
29 | publish\
30 | true
31 | Disk
32 | false
33 | Foreground
34 | 7
35 | Days
36 | false
37 | false
38 | true
39 | 0
40 | 1.0.0.%2a
41 | false
42 | true
43 |
44 |
45 | true
46 | full
47 | false
48 | bin\Debug\
49 | TRACE;DEBUG
50 | prompt
51 | 4
52 | true
53 | AnyCPU
54 | false
55 |
56 |
57 | none
58 | true
59 | bin\Release\
60 | TRACE
61 | prompt
62 | 4
63 | x86
64 | false
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 | False
84 | .NET Framework 3.5 SP1 Client Profile
85 | false
86 |
87 |
88 | False
89 | .NET Framework 3.5 SP1
90 | true
91 |
92 |
93 | False
94 | Windows Installer 3.1
95 | true
96 |
97 |
98 |
99 |
100 | PreserveNewest
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 | {657dbc6d-c3ea-4398-a3fa-ddb73c14f71b}
109 | Agg
110 |
111 |
112 | {9b062971-a88e-4a3d-b3c9-12b78d15fa66}
113 | clipper_library
114 |
115 |
116 | {7e61a5bd-e78f-4b80-88c9-3821b4fa062e}
117 | Csg
118 |
119 |
120 | {94838988-523c-4b11-ad82-8b9b76f23a31}
121 | DataConverters2D
122 |
123 |
124 | {74f6bb6c-9d02-4512-a59a-21940e35c532}
125 | Gui
126 |
127 |
128 | {670bddff-927b-425d-9dd1-22acb14356eb}
129 | PlatformWin32
130 |
131 |
132 | {86f6aaf2-9b50-40b8-a427-1897d76471c5}
133 | PolygonMesh
134 |
135 |
136 | {545b6912-77ff-4b34-ba76-6c3d6a32be6a}
137 | RenderOpenGl
138 |
139 |
140 | {ae37de1f-22f7-49ee-8732-fc6bc8dc58d9}
141 | Tesselate
142 |
143 |
144 | {d3e41b4e-bfbb-44ca-94c8-95c00f754fdd}
145 | VectorMath
146 |
147 |
148 |
--------------------------------------------------------------------------------
/MatterCadGui/MatterCadGui.csproj.user:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | publish\
5 |
6 |
7 |
8 |
9 |
10 | en-US
11 | false
12 | ProjectFiles
13 |
14 |
--------------------------------------------------------------------------------
/MatterCadGui/MatterCadGui.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MatterCadGui", "MatterCadGui.csproj", "{A20459AD-3006-402C-952C-F4A9D9969A87}"
7 | ProjectSection(ProjectDependencies) = postProject
8 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B} = {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AGG", "..\..\agg-sharp\agg\AGG.csproj", "{657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}"
12 | EndProject
13 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tesselate", "..\..\agg-sharp\Tesselate\Tesselate.csproj", "{AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}"
14 | EndProject
15 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformWin32", "..\..\agg-sharp\PlatformWin32\PlatformWin32.csproj", "{670BDDFF-927B-425D-9DD1-22ACB14356EB}"
16 | EndProject
17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Csg", "..\..\agg-sharp\Csg\Csg.csproj", "{7E61A5BD-E78F-4B80-88C9-3821B4FA062E}"
18 | EndProject
19 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VectorMath", "..\..\agg-sharp\VectorMath\VectorMath.csproj", "{D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}"
20 | EndProject
21 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PolygonMesh", "..\..\agg-sharp\PolygonMesh\PolygonMesh.csproj", "{86F6AAF2-9B50-40B8-A427-1897D76471C5}"
22 | EndProject
23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenderOpenGl", "..\..\agg-sharp\RenderOpenGl\RenderOpenGl.csproj", "{545B6912-77FF-4B34-BA76-6C3D6A32BE6A}"
24 | EndProject
25 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gui", "..\..\agg-sharp\Gui\Gui.csproj", "{74F6BB6C-9D02-4512-A59A-21940E35C532}"
26 | EndProject
27 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGlGui", "..\..\agg-sharp\OpenGlGui\OpenGlGui.csproj", "{C958F745-156E-4BDC-A24A-3721C7BE7B8A}"
28 | EndProject
29 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsFileDialogs", "..\..\agg-sharp\WindowsFileDialogs\WindowsFileDialogs.csproj", "{A526DC5D-65F3-461B-805F-D3AC9665F5C9}"
30 | EndProject
31 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlatformAbstract", "..\..\agg-sharp\PlatformAbstract\PlatformAbstract.csproj", "{3E4AABA8-D85F-4922-88C6-5C1B2D2308FB}"
32 | EndProject
33 | Global
34 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
35 | Debug|Any CPU = Debug|Any CPU
36 | Release|Any CPU = Release|Any CPU
37 | Release64|Any CPU = Release64|Any CPU
38 | EndGlobalSection
39 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
40 | {A20459AD-3006-402C-952C-F4A9D9969A87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41 | {A20459AD-3006-402C-952C-F4A9D9969A87}.Debug|Any CPU.Build.0 = Debug|Any CPU
42 | {A20459AD-3006-402C-952C-F4A9D9969A87}.Release|Any CPU.ActiveCfg = Release|Any CPU
43 | {A20459AD-3006-402C-952C-F4A9D9969A87}.Release|Any CPU.Build.0 = Release|Any CPU
44 | {A20459AD-3006-402C-952C-F4A9D9969A87}.Release64|Any CPU.ActiveCfg = Release|Any CPU
45 | {A20459AD-3006-402C-952C-F4A9D9969A87}.Release64|Any CPU.Build.0 = Release|Any CPU
46 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}.Debug|Any CPU.Build.0 = Debug|Any CPU
48 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}.Release|Any CPU.ActiveCfg = Release|Any CPU
49 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}.Release|Any CPU.Build.0 = Release|Any CPU
50 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}.Release64|Any CPU.ActiveCfg = Release|Any CPU
51 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}.Release64|Any CPU.Build.0 = Release|Any CPU
52 | {AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
53 | {AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}.Debug|Any CPU.Build.0 = Debug|Any CPU
54 | {AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}.Release|Any CPU.ActiveCfg = Release|Any CPU
55 | {AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}.Release|Any CPU.Build.0 = Release|Any CPU
56 | {AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}.Release64|Any CPU.ActiveCfg = Release|Any CPU
57 | {AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}.Release64|Any CPU.Build.0 = Release|Any CPU
58 | {670BDDFF-927B-425D-9DD1-22ACB14356EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59 | {670BDDFF-927B-425D-9DD1-22ACB14356EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
60 | {670BDDFF-927B-425D-9DD1-22ACB14356EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
61 | {670BDDFF-927B-425D-9DD1-22ACB14356EB}.Release|Any CPU.Build.0 = Release|Any CPU
62 | {670BDDFF-927B-425D-9DD1-22ACB14356EB}.Release64|Any CPU.ActiveCfg = Release|Any CPU
63 | {670BDDFF-927B-425D-9DD1-22ACB14356EB}.Release64|Any CPU.Build.0 = Release|Any CPU
64 | {7E61A5BD-E78F-4B80-88C9-3821B4FA062E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
65 | {7E61A5BD-E78F-4B80-88C9-3821B4FA062E}.Debug|Any CPU.Build.0 = Debug|Any CPU
66 | {7E61A5BD-E78F-4B80-88C9-3821B4FA062E}.Release|Any CPU.ActiveCfg = Release|Any CPU
67 | {7E61A5BD-E78F-4B80-88C9-3821B4FA062E}.Release|Any CPU.Build.0 = Release|Any CPU
68 | {7E61A5BD-E78F-4B80-88C9-3821B4FA062E}.Release64|Any CPU.ActiveCfg = Release|Any CPU
69 | {7E61A5BD-E78F-4B80-88C9-3821B4FA062E}.Release64|Any CPU.Build.0 = Release|Any CPU
70 | {D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71 | {D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
72 | {D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
73 | {D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}.Release|Any CPU.Build.0 = Release|Any CPU
74 | {D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}.Release64|Any CPU.ActiveCfg = Release|Any CPU
75 | {D3E41B4E-BFBB-44CA-94C8-95C00F754FDD}.Release64|Any CPU.Build.0 = Release|Any CPU
76 | {86F6AAF2-9B50-40B8-A427-1897D76471C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
77 | {86F6AAF2-9B50-40B8-A427-1897D76471C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
78 | {86F6AAF2-9B50-40B8-A427-1897D76471C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
79 | {86F6AAF2-9B50-40B8-A427-1897D76471C5}.Release|Any CPU.Build.0 = Release|Any CPU
80 | {86F6AAF2-9B50-40B8-A427-1897D76471C5}.Release64|Any CPU.ActiveCfg = Release|Any CPU
81 | {86F6AAF2-9B50-40B8-A427-1897D76471C5}.Release64|Any CPU.Build.0 = Release|Any CPU
82 | {545B6912-77FF-4B34-BA76-6C3D6A32BE6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83 | {545B6912-77FF-4B34-BA76-6C3D6A32BE6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
84 | {545B6912-77FF-4B34-BA76-6C3D6A32BE6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
85 | {545B6912-77FF-4B34-BA76-6C3D6A32BE6A}.Release|Any CPU.Build.0 = Release|Any CPU
86 | {545B6912-77FF-4B34-BA76-6C3D6A32BE6A}.Release64|Any CPU.ActiveCfg = Release|Any CPU
87 | {545B6912-77FF-4B34-BA76-6C3D6A32BE6A}.Release64|Any CPU.Build.0 = Release|Any CPU
88 | {74F6BB6C-9D02-4512-A59A-21940E35C532}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
89 | {74F6BB6C-9D02-4512-A59A-21940E35C532}.Debug|Any CPU.Build.0 = Debug|Any CPU
90 | {74F6BB6C-9D02-4512-A59A-21940E35C532}.Release|Any CPU.ActiveCfg = Release|Any CPU
91 | {74F6BB6C-9D02-4512-A59A-21940E35C532}.Release|Any CPU.Build.0 = Release|Any CPU
92 | {74F6BB6C-9D02-4512-A59A-21940E35C532}.Release64|Any CPU.ActiveCfg = Release|Any CPU
93 | {74F6BB6C-9D02-4512-A59A-21940E35C532}.Release64|Any CPU.Build.0 = Release|Any CPU
94 | {C958F745-156E-4BDC-A24A-3721C7BE7B8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95 | {C958F745-156E-4BDC-A24A-3721C7BE7B8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
96 | {C958F745-156E-4BDC-A24A-3721C7BE7B8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
97 | {C958F745-156E-4BDC-A24A-3721C7BE7B8A}.Release|Any CPU.Build.0 = Release|Any CPU
98 | {C958F745-156E-4BDC-A24A-3721C7BE7B8A}.Release64|Any CPU.ActiveCfg = Release|Any CPU
99 | {C958F745-156E-4BDC-A24A-3721C7BE7B8A}.Release64|Any CPU.Build.0 = Release|Any CPU
100 | {A526DC5D-65F3-461B-805F-D3AC9665F5C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
101 | {A526DC5D-65F3-461B-805F-D3AC9665F5C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
102 | {A526DC5D-65F3-461B-805F-D3AC9665F5C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
103 | {A526DC5D-65F3-461B-805F-D3AC9665F5C9}.Release|Any CPU.Build.0 = Release|Any CPU
104 | {A526DC5D-65F3-461B-805F-D3AC9665F5C9}.Release64|Any CPU.ActiveCfg = Release|Any CPU
105 | {A526DC5D-65F3-461B-805F-D3AC9665F5C9}.Release64|Any CPU.Build.0 = Release|Any CPU
106 | {3E4AABA8-D85F-4922-88C6-5C1B2D2308FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
107 | {3E4AABA8-D85F-4922-88C6-5C1B2D2308FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
108 | {3E4AABA8-D85F-4922-88C6-5C1B2D2308FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
109 | {3E4AABA8-D85F-4922-88C6-5C1B2D2308FB}.Release|Any CPU.Build.0 = Release|Any CPU
110 | {3E4AABA8-D85F-4922-88C6-5C1B2D2308FB}.Release64|Any CPU.ActiveCfg = Release64|Any CPU
111 | {3E4AABA8-D85F-4922-88C6-5C1B2D2308FB}.Release64|Any CPU.Build.0 = Release64|Any CPU
112 | EndGlobalSection
113 | GlobalSection(SolutionProperties) = preSolution
114 | HideSolutionNode = FALSE
115 | EndGlobalSection
116 | GlobalSection(MonoDevelopProperties) = preSolution
117 | StartupItem = MatterCADGui.csproj
118 | EndGlobalSection
119 | EndGlobal
120 |
--------------------------------------------------------------------------------
/MatterCadGui/MatterCadGuiWidget.cs:
--------------------------------------------------------------------------------
1 | ///*
2 | //Copyright (c) 2012, Lars Brubaker
3 | //All rights reserved.
4 |
5 | //Redistribution and use in source and binary forms, with or without
6 | //modification, are permitted provided that the following conditions are met:
7 |
8 | //1. Redistributions of source code must retain the above copyright notice, this
9 | // list of conditions and the following disclaimer.
10 | //2. Redistributions in binary form must reproduce the above copyright notice,
11 | // this list of conditions and the following disclaimer in the documentation
12 | // and/or other materials provided with the distribution.
13 |
14 | //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 | //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 | //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | //DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 | //ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 | //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 | //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 | //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 | //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 |
25 | //The views and conclusions contained in the software and documentation are those
26 | //of the authors and should not be interpreted as representing official policies,
27 | //either expressed or implied, of the FreeBSD Project.
28 | //*/
29 |
30 |
31 | using MatterHackers.MatterCadGui;
32 | using MatterHackers.PolygonMesh.Processors;
33 | using System;
34 | using System.Globalization;
35 | using System.IO;
36 |
37 | namespace MatterHackers.MatterCad
38 | {
39 | public class MatterCadGuiWidget : GuiWidget
40 | {
41 | PolygonMesh.Mesh meshToRender = null;
42 |
43 | TrackballTumbleWidget trackBallWidget;
44 | Button outputScad;
45 | Splitter verticleSpliter;
46 |
47 | GuiWidget objectEditorView;
48 | FlowLayoutWidget objectEditorList;
49 | FlowLayoutWidget textSide;
50 |
51 | TextEditWidget textEdit;
52 |
53 | Union rootUnion = new Union("root");
54 |
55 |
56 |
57 | public MatterCadGuiWidget()
58 | {
59 | //rootUnion.Add(DemoProjects.PowerSupply()); //works but cutout is not working
60 | rootUnion.Add(SimplePartTester.Assembly());
61 | //rootUnion.Add(new BoxPrimitive(8, 20, 10));
62 |
63 | //rootUnion.Add(new LinearExtrude(new double[] { 1.1, 2.2, 3.3, 6.3 }, 7));
64 | //rootUnion.Add(
65 | // new Difference (new Translate(new Cylinder(10, 40), 5, 10, 5), new Translate(new BoxPrimitive(10, 10, 20,"test",true), 5, 20, 5)));
66 | SuspendLayout();
67 | verticleSpliter = new Splitter();
68 |
69 | // pannel 1 stuff
70 | textSide = new FlowLayoutWidget(FlowDirection.TopToBottom);
71 |
72 | objectEditorView = new GuiWidget(300, 500);
73 | objectEditorList = new FlowLayoutWidget();
74 |
75 | textEdit = new TextEditWidget("test", 300, 400);
76 | textEdit.HAnchor = HAnchor.ParentLeftRight;
77 | // textEdit.MinimumSize = new Vector2(Math.Max(textEdit.MinimumSize.x, pixelWidth), Math.Max(textEdit.MinimumSize.y, pixelHeight));
78 | textEdit.VAnchor = VAnchor.ParentBottomTop;
79 | textEdit.Multiline = true;
80 | textEdit.BackgroundColor = RGBA_Bytes.Yellow;
81 |
82 | // objectEditorList.AddChild(textEdit);//CsgEditorBase.CreateEditorForCsg(rootUnion));
83 | // objectEditorView.AddChild(objectEditorList);
84 | // objectEditorView.BackgroundColor = RGBA_Bytes.Orange;
85 | // objectEditorView.Text = "Hello World!";
86 | objectEditorView.LocalBounds = new RectangleDouble(0, 0, 200, 300);
87 | textSide.LocalBounds = new RectangleDouble(0, 0, 200, 300);
88 | // objectEditorView.DebugShowBounds = true;
89 | textSide.AddChild(textEdit);
90 | textSide.BoundsChanged += new EventHandler(textSide_BoundsChanged);
91 |
92 | FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
93 |
94 | Button loadMatterScript = new Button("Load Matter Script");
95 | loadMatterScript.Click += loadMatterScript_Click;
96 | topButtonBar.AddChild(loadMatterScript);
97 |
98 | outputScad = new Button("Output SCAD");
99 | outputScad.Click += OutputScad_Click;
100 | topButtonBar.AddChild(outputScad);
101 |
102 | textSide.AddChild(topButtonBar);
103 |
104 | FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
105 |
106 | Button loadStl = new Button("Load STL");
107 | loadStl.Click += LoadStl_Click;
108 | bottomButtonBar.AddChild(loadStl);
109 |
110 | textSide.AddChild(bottomButtonBar);
111 |
112 | // // pannel 2 stuff
113 | FlowLayoutWidget renderSide = new FlowLayoutWidget(FlowDirection.TopToBottom);
114 | renderSide.AnchorAll();
115 |
116 | trackBallWidget = new TrackballTumbleWidget();
117 | trackBallWidget.DrawGlContent += new EventHandler(glLightedView_DrawGlContent);
118 | renderSide.AddChild(trackBallWidget);
119 |
120 | verticleSpliter.Panel2.AddChild(renderSide);
121 | verticleSpliter.Panel1.AddChild(textSide);
122 |
123 |
124 | ResumeLayout();
125 | objectEditorView.AnchorAll();
126 | AnchorAll();
127 | verticleSpliter.AnchorAll();
128 | textSide.AnchorAll();
129 | trackBallWidget.AnchorAll();
130 | AddChild(verticleSpliter);
131 | BackgroundColor = RGBA_Bytes.White;
132 | }
133 |
134 | public override void OnParentChanged(EventArgs e)
135 | {
136 | verticleSpliter.SplitterDistance = Parent.Width / 2;
137 | base.OnParentChanged(e);
138 | }
139 |
140 | private void LoadStl_Click(object sender, EventArgs e)
141 | {
142 | OpenFileDialogParams opeParams = new OpenFileDialogParams("STL Files|*.stl");
143 |
144 | FileDialog.OpenFileDialog(opeParams, (openParams) =>
145 | {
146 | var streamToLoadFrom = File.Open(openParams.FileName, FileMode.Open);
147 |
148 | if (streamToLoadFrom != null)
149 | {
150 | var loadedFileName = openParams.FileName;
151 |
152 | meshToRender = StlProcessing.Load(streamToLoadFrom);
153 |
154 | ImageBuffer plateInventory = new ImageBuffer((int)(300 * 8.5), 300 * 11, 32, new BlenderBGRA());
155 | Graphics2D plateGraphics = plateInventory.NewGraphics2D();
156 | plateGraphics.Clear(RGBA_Bytes.White);
157 |
158 | double inchesPerMm = 0.0393701;
159 | double pixelsPerInch = 300;
160 | double pixelsPerMm = inchesPerMm * pixelsPerInch;
161 | AxisAlignedBoundingBox aabb = meshToRender.GetAxisAlignedBoundingBox();
162 | Vector2 lowerLeftInMM = new Vector2(-aabb.minXYZ.x, -aabb.minXYZ.y);
163 | Vector3 centerInMM = (aabb.maxXYZ - aabb.minXYZ) / 2;
164 | Vector2 offsetInMM = new Vector2(20, 30);
165 |
166 | {
167 | RectangleDouble bounds = new RectangleDouble(offsetInMM.x * pixelsPerMm,
168 | offsetInMM.y * pixelsPerMm,
169 | (offsetInMM.x + aabb.maxXYZ.x - aabb.minXYZ.x) * pixelsPerMm,
170 | (offsetInMM.y + aabb.maxXYZ.y - aabb.minXYZ.y) * pixelsPerMm);
171 | bounds.Inflate(3 * pixelsPerMm);
172 | RoundedRect rect = new RoundedRect(bounds, 3 * pixelsPerMm);
173 | plateGraphics.Render(rect, RGBA_Bytes.LightGray);
174 | Stroke rectOutline = new Stroke(rect, .5 * pixelsPerMm);
175 | plateGraphics.Render(rectOutline, RGBA_Bytes.DarkGray);
176 | }
177 |
178 | OrthographicZProjection.DrawTo(plateGraphics, meshToRender, lowerLeftInMM + offsetInMM, pixelsPerMm);
179 | plateGraphics.DrawString(Path.GetFileName(openParams.FileName), (offsetInMM.x + centerInMM.x) * pixelsPerMm, (offsetInMM.y - 10) * pixelsPerMm, 50, Agg.Font.Justification.Center);
180 |
181 | //ImageBuffer logoImage = new ImageBuffer();
182 | //ImageIO.LoadImageData("Logo.png", logoImage);
183 | //plateGraphics.Render(logoImage, (plateInventory.Width - logoImage.Width) / 2, plateInventory.Height - logoImage.Height - 10 * pixelsPerMm);
184 |
185 | //ImageIO.SaveImageData("plate Inventory.jpeg", plateInventory);
186 | }
187 | });
188 | }
189 |
190 | void textSide_BoundsChanged(object sender, EventArgs e)
191 | {
192 | objectEditorView.LocalBounds = new RectangleDouble(0, 0, ((GuiWidget)sender).Width - 10, objectEditorView.Height);
193 | Invalidate();
194 | }
195 |
196 | void glLightedView_DrawGlContent(object sender, EventArgs e)
197 | {
198 | if (rootUnion != null)
199 | {
200 | RenderCsgToGl.Render(rootUnion);
201 | }
202 | if (meshToRender != null)
203 | {
204 | RenderMeshToGl.Render(meshToRender, RGBA_Bytes.Gray);
205 | }
206 | }
207 |
208 |
209 | void loadMatterScript_Click(object sender, EventArgs mouseEvent)
210 | {
211 | OpenFileDialogParams openParams = new OpenFileDialogParams("MatterScript Files, c-sharp code|*.part;*.cs");
212 |
213 | FileDialog.OpenFileDialog(openParams, (streamToLoadFrom) =>
214 | {
215 |
216 | if (streamToLoadFrom != null)
217 | {
218 | SuspendLayout();
219 | var loadedFileName = openParams.FileName;
220 | string extension = Path.GetExtension(openParams.FileName).ToUpper(CultureInfo.InvariantCulture);
221 | //if (extension == ".CS")
222 | //{
223 | //}
224 | //else if (extension == ".VB")
225 | //{
226 | //}
227 |
228 | string text = File.ReadAllText(loadedFileName);
229 |
230 | StreamReader streamReader = new StreamReader(streamToLoadFrom.FileName);
231 | textEdit.Text = streamReader.ReadToEnd();
232 | streamReader.Close();
233 |
234 | verticleSpliter.SplitterDistance = verticleSpliter.SplitterDistance - 1;
235 | verticleSpliter.SplitterDistance = verticleSpliter.SplitterDistance + 1;
236 |
237 | ResumeLayout();
238 | AnchorAll();
239 | verticleSpliter.AnchorAll();
240 | textSide.AnchorAll();
241 | objectEditorView.Invalidate();
242 | textSide.PerformLayout();
243 | trackBallWidget.AnchorAll();
244 | Invalidate();
245 | }
246 | });
247 |
248 | }
249 | private void OutputScad_Click(object sender, EventArgs e)
250 | {
251 | if (rootUnion != null)
252 | {
253 | SaveFileDialogParams saveParams = new SaveFileDialogParams("Text files (*.scad)|*.scad");
254 | FileDialog.SaveFileDialog(saveParams, (streamToSaveTo) =>
255 | {
256 | if (streamToSaveTo != null)
257 | {
258 | OpenSCadOutput.Save(rootUnion, streamToSaveTo.FileName);//"c:/output.scad")
259 | }
260 | });
261 | }
262 | }
263 |
264 | public override void OnDraw(Graphics2D graphics2D)
265 | {
266 | graphics2D.Clear(RGBA_Bytes.White);
267 | base.OnDraw(graphics2D);
268 | }
269 | }
270 | }
271 |
--------------------------------------------------------------------------------
/MatterCadGui/Microsoft.Scripting.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/MatterCadGui/Microsoft.Scripting.dll
--------------------------------------------------------------------------------
/MatterCadGui/OrthographicZProjection.cs:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012, Lars Brubaker
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 | 2. Redistributions in binary form must reproduce the above copyright notice,
11 | this list of conditions and the following disclaimer in the documentation
12 | and/or other materials provided with the distribution.
13 |
14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 |
25 | The views and conclusions contained in the software and documentation are those
26 | of the authors and should not be interpreted as representing official policies,
27 | either expressed or implied, of the FreeBSD Project.
28 | */
29 |
30 |
31 |
32 | using MatterHackers.Agg;
33 | using MatterHackers.Agg.VertexSource;
34 | using MatterHackers.VectorMath;
35 |
36 | namespace MatterHackers.PolygonMesh.Processors
37 | {
38 | public static class OrthographicZProjection
39 | {
40 | public static void DrawTo(Graphics2D graphics2D, Mesh meshToDraw, Vector2 offset, double scale)
41 | {
42 | foreach (Face face in meshToDraw.Faces)
43 | {
44 | PathStorage polygonProjected = new PathStorage();
45 | bool first = true;
46 | foreach (FaceEdge faceEdge in face.FaceEdges())
47 | {
48 | Vector2 position = new Vector2(faceEdge.firstVertex.Position.x, faceEdge.firstVertex.Position.y);
49 | position += offset;
50 | position *= scale;
51 | if (first)
52 | {
53 | polygonProjected.MoveTo(position.x, position.y);
54 | first = false;
55 | }
56 | else
57 | {
58 | polygonProjected.LineTo(position.x, position.y);
59 | }
60 | }
61 | graphics2D.Render(polygonProjected, RGBA_Bytes.Blue);
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/MatterCadGui/Parts/PSEyeHolder.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using MatterHackers.Csg;
3 | using MatterHackers.Csg.Operations;
4 | using MatterHackers.Csg.Processors;
5 | using MatterHackers.Csg.Solids;
6 | using MatterHackers.Csg.Transform;
7 | using MatterHackers.VectorMath;
8 |
9 | namespace SimplePartScripting
10 | {
11 | class SimplePartTester
12 | {
13 | public static CsgObject SimplePartFunction()
14 | {
15 | double pcbHoldLip = 2;
16 | double standYDepth = 8;
17 | double pcbYDepth = 2;
18 | CsgObject pcbTotal;
19 |
20 | CsgObject pcbBottom = new Box(23, pcbYDepth, 40);
21 | pcbTotal = pcbBottom;
22 |
23 | CsgObject pcbMid = new Box(30, pcbYDepth, 34.5);
24 | pcbMid = new Align(pcbMid, Face.Top, pcbBottom, Face.Top);
25 | pcbMid = new SetCenter(pcbMid, pcbBottom.GetCenter(), true, false, false);
26 | pcbTotal += pcbMid;
27 |
28 | CsgObject pcbTop = new Box(64.5, pcbYDepth, 21.5);
29 | pcbTop = new Align(pcbTop, Face.Top, pcbBottom, Face.Top);
30 | pcbTop = new SetCenter(pcbTop, pcbBottom.GetCenter(), true, false, false);
31 | pcbTotal += pcbTop;
32 |
33 | Box standBaseBox = new Box(pcbTop.XSize + 2 * (standYDepth - pcbHoldLip), 37, standYDepth);
34 | //standBaseBox.BevelFace(Face.Top, 3);
35 | //standBaseBox.BevelEdge(Face.Left | Face.Front, 3);
36 | //standBaseBox.BevelEdge(Face.Left | Face.Back, 3);
37 | //standBaseBox.BevelEdge(Face.Right | Face.Front, 3);
38 | //standBaseBox.BevelEdge(Face.Right | Face.Back, 3);
39 | CsgObject standBase = standBaseBox;
40 | CsgObject standTotal = standBase;
41 |
42 | Box standSideSupportLeftBox = new Box(standYDepth, standYDepth, pcbBottom.ZSize + standBase.ZSize - 10);
43 | //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Front, 3);
44 | //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Back, 3);
45 | //standSideSupportLeftBox.BevelEdge(Face.Left | Face.Top, 3);
46 | //standSideSupportLeftBox.BevelEdge(Face.Right | Face.Front, 1);
47 | //standSideSupportLeftBox.BevelEdge(Face.Right | Face.Back, 1);
48 | CsgObject standSideSupportLeft = standSideSupportLeftBox;
49 | standSideSupportLeft = new SetCenter(standSideSupportLeft, standBase.GetCenter(), false, true, false);
50 | standSideSupportLeft = new Align(standSideSupportLeft, Face.Bottom | Face.Left, standBase, Face.Bottom | Face.Left);
51 | standTotal += standSideSupportLeft;
52 |
53 | Box insideBevelLeftBox = new Box(standYDepth, standYDepth, standYDepth);
54 | insideBevelLeftBox.CutAlongDiagonal(Face.Left | Face.Bottom);
55 | CsgObject insideBevelLeft = insideBevelLeftBox;
56 | insideBevelLeft = new Align(insideBevelLeft, Face.Left | Face.Front, standSideSupportLeft, Face.Right | Face.Front, -1, 0, -.1);
57 | insideBevelLeft = new Align(insideBevelLeft, Face.Bottom, standBase, Face.Top);
58 | standTotal += insideBevelLeft;
59 |
60 | Box standSideSupportRightBox = new Box(standYDepth, standYDepth, pcbBottom.ZSize + standBase.ZSize - 10);
61 | //standSideSupportRightBox.BevelEdge(Face.Right | Face.Front, 3);
62 | //standSideSupportRightBox.BevelEdge(Face.Right | Face.Back, 3);
63 | //standSideSupportRightBox.BevelEdge(Face.Right | Face.Top, 3);
64 | //standSideSupportRightBox.BevelEdge(Face.Left | Face.Front, 1);
65 | //standSideSupportRightBox.BevelEdge(Face.Left | Face.Back, 1);
66 | CsgObject standSideSupportRight = standSideSupportRightBox;
67 | standSideSupportRight = new SetCenter(standSideSupportRight, standBase.GetCenter(), false, true, false);
68 | standSideSupportRight = new Align(standSideSupportRight, Face.Bottom | Face.Right, standBase, Face.Bottom | Face.Right);
69 | standTotal += standSideSupportRight;
70 |
71 | Box insideBevelRightBox = new Box(standYDepth, standYDepth, standYDepth);
72 | insideBevelRightBox.CutAlongDiagonal(Face.Right | Face.Bottom);
73 | CsgObject insideBevelRight = insideBevelRightBox;
74 | insideBevelRight = new Align(insideBevelRight, Face.Right | Face.Front, standSideSupportRight, Face.Left | Face.Front, 1, 0, -.1);
75 | insideBevelRight = new Align(insideBevelRight, Face.Bottom, standBase, Face.Top);
76 | standTotal += insideBevelRight;
77 |
78 | CsgObject ringCutOut = new Cylinder(11, 6, Alignment.y);
79 | ringCutOut = new SetCenter(ringCutOut, standBase.GetCenter());
80 | ringCutOut = new Align(ringCutOut, Face.Bottom | Face.Back, standBase, Face.Top | Face.Front, 0, 5.9, -4);
81 | standTotal -= ringCutOut;
82 |
83 | pcbTotal = new SetCenter(pcbTotal, standBase.GetCenter(), true, true, false);
84 | pcbTotal = new Align(pcbTotal, Face.Bottom, standBase, Face.Top, offsetZ: -pcbHoldLip);
85 | standTotal -= pcbTotal;
86 |
87 | return standTotal;
88 | }
89 |
90 | static void Main()
91 | {
92 | CsgObject part = SimplePartFunction();
93 | OpenSCadOutput.Save(part, "temp.scad");
94 |
95 | System.Console.WriteLine("Output the file to 'temp.scad'.");
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/MatterCadGui/Parts/TrainConnector.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using MatterHackers.Csg;
3 | using MatterHackers.Csg.Operations;
4 | using MatterHackers.Csg.Processors;
5 | using MatterHackers.Csg.Solids;
6 | using MatterHackers.Csg.Transform;
7 | using MatterHackers.VectorMath;
8 |
9 | namespace SimplePartScripting
10 | {
11 | class SimplePartTester
12 | {
13 | public static CsgObject SimplePartFunction()
14 | {
15 | CsgObject total;
16 | CsgObject bar = new Box(20, 5.8, 12, "link");
17 | bar = new SetCenter(bar, Vector3.Zero);
18 | total = bar;
19 | CsgObject leftHold = new Cylinder(11.7 / 2, 12, Alignment.z);
20 | leftHold = new SetCenter(leftHold, bar.GetCenter() + new Vector3(12, 0, 0));
21 | CsgObject rightHold = leftHold.NewMirrorAccrossX();
22 | total += leftHold;
23 | total += rightHold;
24 |
25 | return total;
26 | }
27 |
28 | static void Main()
29 | {
30 | CsgObject part = SimplePartFunction();
31 | OpenSCadOutput.Save(part, "temp.scad");
32 |
33 | System.Console.WriteLine("Output the file to 'temp.scad'.");
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/MatterCadGui/Parts/test.part:
--------------------------------------------------------------------------------
1 | Box(20, 5.8, 12)
2 |
--------------------------------------------------------------------------------
/MatterCadGui/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/OpenCSharpCad/.gitignore:
--------------------------------------------------------------------------------
1 | /obj
2 | /bin
3 |
--------------------------------------------------------------------------------
/OpenCSharpCad/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/OpenCSharpCad/MainWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using MatterHackers.Agg;
3 | using MatterHackers.Agg.UI;
4 | using MatterHackers.Csg.Operations;
5 | using MatterHackers.VectorMath;
6 |
7 | using System.CodeDom.Compiler;
8 | using System.Text;
9 | using MatterHackers.Csg.Transform;
10 | using MatterHackers.Csg.Solids;
11 |
12 | namespace OpenCSharpCad
13 | {
14 | public class MainWindow : SystemWindow
15 | {
16 | //private MatterHackers.PolygonMesh.Mesh meshToRender = null;
17 |
18 | private TrackballTumbleWidget trackBallWidget;
19 | private Button outputScad;
20 | private Splitter verticleSpliter;
21 |
22 | private GuiWidget objectEditorView;
23 | private FlowLayoutWidget objectEditorList;
24 | private FlowLayoutWidget textSide;
25 | private TextEditWidget hello;
26 | private Union rootUnion = new Union("root");
27 | dynamic classRef;
28 |
29 | public MainWindow(bool renderRayTrace) : base(800, 600)
30 | {
31 | // rootUnion.Add(new Translate(new BoxPrimitive(10, 10, 20), 5, 10, 5));
32 | //rootUnion.Add(new Box(8, 20, 10));
33 | //rootUnion.Add(new Cylinder(10, 40));
34 | // rootUnion.Add(new Translate(new Sphere(radius: 30), 15, 20, 40)); //not implemented
35 | var testUnion = new Translate(new Box(10, 10, 20) - new Box(8, 20, 10), 5, 5, 5); //new Difference(
36 | // rootUnion.Add(new LinearExtrude(new double[] { 1.1, 2.2, 3.3, 6.3 }, 7));
37 | //rootUnion.Add(testUnion);
38 | rootUnion.Box(8, 20, 40);
39 | rootUnion.Add(new Translate(new BoxPrimitive(10, 10, 20), 5, 10, 5));
40 | rootUnion.Add(new BoxPrimitive(8, 20, 10));
41 | SuspendLayout();
42 | verticleSpliter = new Splitter();
43 | {
44 | // panel 1 stuff
45 | textSide = new FlowLayoutWidget(FlowDirection.TopToBottom);
46 | {
47 | objectEditorView = new GuiWidget(300, 500);
48 | objectEditorList = new FlowLayoutWidget();
49 | // objectEditorList.AddChild(new TextEditWidget("Text in box"));
50 |
51 | // objectEditorView.AddChild(objectEditorList);
52 | objectEditorView.BackgroundColor = RGBA_Bytes.LightGray;
53 | // matterScriptEditor.LocalBounds = new RectangleDouble(0, 0, 200, 300);
54 | // textSide.AddChild(objectEditorView);
55 | var code = new StringBuilder();
56 |
57 | code.AppendLine("new Box(8, 20, 10);");
58 | //code.AppendLine("MatterHackers.PolygonMesh.Mesh mesh = new MatterHackers.PolygonMesh.Mesh();");
59 | //code.AppendLine("var v0 = mesh.CreateVertex(new Vector3(1, 0, 1)); // V0");
60 | //code.AppendLine("var v1 = mesh.CreateVertex(new Vector3(1, 0, -1)); // V1");
61 | //code.AppendLine("var v2 = mesh.CreateVertex(new Vector3(-1, 0, -1)); // V2");
62 | //code.AppendLine("var v3 = mesh.CreateVertex(new Vector3(-1, 0, 1)); // V3");
63 | //code.AppendLine("var v4 = mesh.CreateVertex(new Vector3(0, 1, 0)); // V4");
64 |
65 | //code.AppendLine("mesh.CreateFace(new Vertex[] { v0, v1, v2, v3 });");
66 | //code.AppendLine("mesh.CreateFace(new Vertex[] { v3, v0, v4 });");
67 | //code.AppendLine("mesh.CreateFace(new Vertex[] { v0, v1, v4 });");
68 | //code.AppendLine("mesh.CreateFace(new Vertex[] { v1, v2, v4 });");
69 | //code.AppendLine("mesh.CreateFace(new Vertex[] { v2, v3, v4 });");
70 |
71 | //code.AppendLine("RenderMeshToGl.Render(mesh, new RGBA_Floats(.3, .8, 7)); ");
72 | hello = new TextEditWidget(code.ToString().Replace('\r', '\n'));
73 | hello.TextChanged += Hello_TextChanged;
74 | hello.Multiline = true;
75 | textSide.AddChild(hello);
76 | objectEditorList.AnchorAll();
77 | // textSide.BoundsChanged += new EventHandler(textSide_BoundsChanged);
78 |
79 | //#region Buttons
80 | //FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
81 |
82 | //Button loadMatterScript = new Button("Load Matter Script");
83 | //// loadMatterScript.Click += loadMatterScript_Click;
84 | //topButtonBar.AddChild(loadMatterScript);
85 |
86 | //outputScad = new Button("Output SCAD");
87 | //// outputScad.Click += outputScad_Click;
88 | //topButtonBar.AddChild(outputScad);
89 |
90 | //textSide.AddChild(topButtonBar);
91 |
92 | //FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
93 |
94 | //Button loadStl = new Button("Load STL");
95 | //// loadStl.Click += LoadStl_Click;
96 | //bottomButtonBar.AddChild(loadStl);
97 |
98 | //textSide.AddChild(bottomButtonBar);
99 |
100 | //#endregion
101 | }
102 |
103 | // pannel 2 stuff
104 | FlowLayoutWidget renderSide = new FlowLayoutWidget(FlowDirection.TopToBottom);
105 | renderSide.AnchorAll();
106 | {
107 | trackBallWidget = new TrackballTumbleWidget();
108 | trackBallWidget.DrawGlContent += new EventHandler(glLightedView_DrawGlContent);
109 | renderSide.AddChild(trackBallWidget);
110 | }
111 | verticleSpliter.Panel2.AddChild(renderSide);
112 | verticleSpliter.Panel1.AddChild(textSide);
113 | }
114 | ResumeLayout();
115 |
116 | AnchorAll();
117 |
118 | verticleSpliter.AnchorAll();
119 |
120 | textSide.AnchorAll();
121 |
122 | trackBallWidget.AnchorAll();
123 |
124 | AddChild(verticleSpliter);
125 |
126 | BackgroundColor = RGBA_Bytes.White;
127 | Compile();
128 | }
129 |
130 | private void Hello_TextChanged(object sender, EventArgs e)
131 | {
132 | Compile();
133 | }
134 |
135 | private void Compile()
136 | {
137 |
138 | StringBuilder sb = new StringBuilder();
139 |
140 | //-----------------
141 | // Create the class as usual
142 | sb.AppendLine("using System;");
143 | sb.AppendLine("using System.Windows.Forms;");
144 | sb.AppendLine("using System.Collections.Generic;");
145 | sb.AppendLine("using MatterHackers.PolygonMesh;");
146 | sb.AppendLine("using MatterHackers.VectorMath; ");
147 | sb.AppendLine("using MatterHackers.Csg.Operations; ");
148 | sb.AppendLine("using MatterHackers.Csg.Solids; ");
149 | sb.AppendLine("using MatterHackers.RenderOpenGl; ");
150 | sb.AppendLine("using MatterHackers.Agg;");
151 |
152 | sb.AppendLine("namespace Test");
153 | sb.AppendLine("{");
154 |
155 | sb.AppendLine(" public class RenderTest");
156 | sb.AppendLine(" {");
157 |
158 | // My pre-defined class named FilterCountries that receive the sourceListBox
159 | sb.AppendLine(" public void Render()");
160 | sb.AppendLine(" {");
161 |
162 | sb.AppendLine(hello.Text);
163 | sb.AppendLine(" }");
164 | sb.AppendLine(" }");
165 | sb.AppendLine("}");
166 |
167 |
168 |
169 |
170 | //-----------------
171 | // The finished code
172 | string classCode = sb.ToString();
173 |
174 | //-----------------
175 | // Dont need any extra assemblies
176 |
177 |
178 | try
179 | {
180 | // / txtErrors.Clear();
181 |
182 | //------------
183 | // Pass the class code, the namespace of the class and the list of extra assemblies needed
184 | classRef = DynCode.CodeHelper.HelperFunction(classCode, "Test.RenderTest", new object[] { });
185 |
186 | //-------------------
187 | // If the compilation process returned an error, then show to the user all errors
188 | if (classRef is CompilerErrorCollection)
189 | {
190 | StringBuilder sberror = new StringBuilder();
191 |
192 | foreach (CompilerError error in (CompilerErrorCollection)classRef)
193 | {
194 | sberror.AppendLine(string.Format("{0}:{1} {2} {3}", error.Line, error.Column, error.ErrorNumber, error.ErrorText));
195 | }
196 |
197 | // txtErrors.Text = sberror.ToString();
198 |
199 | return;
200 | }
201 | }
202 | catch (Exception ex)
203 | {
204 | Console.WriteLine(ex.Message);
205 | // If something very bad happened then throw it
206 | // MessageBox.Show(ex.Message);
207 | throw;
208 | }
209 | }
210 | private void glLightedView_DrawGlContent(object sender, EventArgs e)
211 | {
212 |
213 | try
214 | {
215 |
216 | classRef.Render();
217 | }
218 | catch (Exception) { }
219 | //-------------
220 | // Finally call the class to filter the countries with the specific routine provided
221 | //List targetValues = classRef.FilterCountries(lstSource);
222 |
223 | ////-------------
224 | //// Move the result to the target listbox
225 | //lstTarget.Items.Clear();
226 | //lstTarget.Items.AddRange(targetValues.ToArray());
227 | }
228 |
229 | private MatterHackers.PolygonMesh.Mesh Pyramid()
230 | {
231 | MatterHackers.PolygonMesh.Mesh mesh = new MatterHackers.PolygonMesh.Mesh();
232 | var v0 = mesh.CreateVertex(new Vector3(1, 0, 1)); // V0
233 | var v1 = mesh.CreateVertex(new Vector3(1, 0, -1)); // V1
234 | var v2 = mesh.CreateVertex(new Vector3(-1, 0, -1)); // V2
235 | var v3 = mesh.CreateVertex(new Vector3(-1, 0, 1)); // V3
236 | var v4 = mesh.CreateVertex(new Vector3(0, 1, 0)); // V4
237 |
238 | mesh.CreateFace(new Vertex[] { v0, v1, v2, v3 });
239 | mesh.CreateFace(new Vertex[] { v3, v0, v4 });
240 | mesh.CreateFace(new Vertex[] { v0, v1, v4 });
241 | mesh.CreateFace(new Vertex[] { v1, v2, v4 });
242 | mesh.CreateFace(new Vertex[] { v2, v3, v4 });
243 |
244 | return mesh;
245 | }
246 |
247 |
248 | [STAThread]
249 | public static void Main(string[] args)
250 | {
251 | MainWindow cadWindow = new MainWindow(true);
252 | cadWindow.UseOpenGL = true;
253 | cadWindow.Title = "OpenCSharpCad";
254 |
255 | cadWindow.ShowAsSystemWindow();
256 | }
257 | }
258 | }
259 |
--------------------------------------------------------------------------------
/OpenCSharpCad/OpenCSharpCad.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {CDBC3B97-D243-4733-8C70-EEA82F7881B0}
8 | WinExe
9 | Properties
10 | OpenCSharpCad
11 | OpenCSharpCad
12 | v4.7.2
13 | 512
14 | true
15 |
16 |
17 |
18 | AnyCPU
19 | true
20 | full
21 | false
22 | bin\Debug\
23 | DEBUG;TRACE
24 | prompt
25 | 4
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | {61e4f649-ac77-41c7-8d65-d2af5ffc9d63}
61 | DynCode
62 |
63 |
64 | {657dbc6d-c3ea-4398-a3fa-ddb73c14f71b}
65 | Agg
66 |
67 |
68 | {7e61a5bd-e78f-4b80-88c9-3821b4fa062e}
69 | Csg
70 |
71 |
72 | {74F6BB6C-9D02-4512-A59A-21940E35C532}
73 | Gui
74 |
75 |
76 | {C958F745-156E-4BDC-A24A-3721C7BE7B8A}
77 | OpenGlGui
78 |
79 |
80 | {670bddff-927b-425d-9dd1-22acb14356eb}
81 | PlatformWin32
82 |
83 |
84 | {7EE4636D-8A92-4015-9562-7FCD6ADD0645}
85 | Net3dBool
86 |
87 |
88 | {86f6aaf2-9b50-40b8-a427-1897d76471c5}
89 | PolygonMesh
90 |
91 |
92 | {545b6912-77ff-4b34-ba76-6c3d6a32be6a}
93 | RenderOpenGl
94 |
95 |
96 | {d3e41b4e-bfbb-44ca-94c8-95c00f754fdd}
97 | VectorMath
98 |
99 |
100 |
101 |
108 |
--------------------------------------------------------------------------------
/OpenCSharpCad/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("OpenCSharpCad")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("OpenCSharpCad")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("cdbc3b97-d243-4733-8c70-eea82f7881b0")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/OpenCSharpCad/Shapes.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.PolygonMesh;
2 | using MatterHackers.VectorMath;
3 | using MatterHackers.Csg.Operations;
4 | using MatterHackers.Csg.Solids;
5 | using MatterHackers.RenderOpenGl;
6 | using MatterHackers.Agg;
7 | using Net3dBool;
8 |
9 | namespace OpenCSharpCad
10 | {
11 | public static class CadShapes
12 | {
13 | public static void Render()
14 | {
15 | MatterHackers.PolygonMesh.Mesh mesh = new MatterHackers.PolygonMesh.Mesh();
16 | var v0 = mesh.CreateVertex(new Vector3(1, 0, 1)); // V0
17 | var v1 = mesh.CreateVertex(new Vector3(1, 0, -1)); // V1
18 | var v2 = mesh.CreateVertex(new Vector3(-1, 0, -1)); // V2
19 | var v3 = mesh.CreateVertex(new Vector3(-1, 0, 1)); // V3
20 | var v4 = mesh.CreateVertex(new Vector3(0, 1, 0)); // V4
21 |
22 | mesh.CreateFace(new Vertex[] { v0, v1, v2, v3 });
23 | mesh.CreateFace(new Vertex[] { v3, v0, v4 });
24 | mesh.CreateFace(new Vertex[] { v0, v1, v4 });
25 | mesh.CreateFace(new Vertex[] { v1, v2, v4 });
26 | mesh.CreateFace(new Vertex[] { v2, v3, v4 });
27 |
28 | RenderMeshToGl.Render(mesh, new Color(.3, .8, 7));
29 | }
30 |
31 | public static void Box(this Union rootUnion, double sizeX, double sizeY, double sizeZ)
32 | {
33 | rootUnion.Add(new Box(sizeX, sizeY, sizeZ));
34 | }
35 |
36 | //public
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # mattercad
2 | Parametric cad using c#
3 |
4 | ## Video
5 | [](https://youtu.be/dlQ3HhHRtSU)
6 |
7 | ## Description
8 | I found some abandoned project to create parametric cad using c#
9 | I love OpenScad and use it a lot, but I am .NET developer so will be grat to have something similar with .NET
10 |
11 | ## Links
12 | Original project from MatterHackers https://www.matterhackers.com/news/mattercad-design-your-3d-parts-in-csharp
13 |
14 |
15 | ## Example
16 | ```C#
17 | CsgObject bar = new Box(20, 5.8, 12, createCentered: false);
18 | ```
19 |
20 | ## Screenshot
21 |
--------------------------------------------------------------------------------
/Screenshot 2018-03-30 22.56.56.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/Screenshot 2018-03-30 22.56.56.png
--------------------------------------------------------------------------------
/Screenshot 2018-03-30 22.57.39.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/roboter/OpenSharpCAD/f1954e433587eb28021a9de445da0bfd7df07dbf/Screenshot 2018-03-30 22.57.39.png
--------------------------------------------------------------------------------
/WindowTest/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/WindowTest/Program.cs:
--------------------------------------------------------------------------------
1 | using MatterHackers.Agg;
2 | using MatterHackers.Agg.UI;
3 | using MatterHackers.Agg.VertexSource;
4 | using MatterHackers.Csg;
5 | using MatterHackers.Csg.Solids;
6 | using MatterHackers.Csg.Transform;
7 | using MatterHackers.VectorMath;
8 | using System;
9 | using System.Collections.Generic;
10 | using System.Linq;
11 | using System.Text;
12 | using System.Threading.Tasks;
13 |
14 | namespace WindowTest
15 | {
16 | class Program
17 | {
18 | [STAThread]
19 | static void Main(string[] args)
20 | {
21 | MatterCadGui cadWindow = new MatterCadGui(true);
22 | cadWindow.UseOpenGL = true;
23 | cadWindow.Title = "MatterCAD";
24 |
25 | cadWindow.ShowAsSystemWindow();
26 | }
27 | }
28 |
29 | public class MatterCadGui : SystemWindow
30 | {
31 | MatterCadGuiWidget matterCadGuiWidget;
32 |
33 | CsgObject TrainConnector()
34 | {
35 | CsgObject total;
36 | CsgObject bar = new Box(20, 5.8, 12, createCentered: false, name: "link");
37 | bar = new SetCenter(bar, Vector3.Zero);
38 | total = bar;
39 | CsgObject leftHold = new Cylinder(11.7 / 2, 12, Alignment.z);
40 | leftHold = new SetCenter(leftHold, bar.GetCenter() + new Vector3(12, 0, 0));
41 | CsgObject rightHold = leftHold.NewMirrorAccrossX();
42 | total += leftHold;
43 | total += rightHold;
44 |
45 | return total;
46 | }
47 | public MatterCadGui(bool renderRayTrace)
48 | : base(800, 600)
49 | {
50 | ////BackgroundColor = RGBA_Bytes.YellowGreen;
51 | //CsgObject testObject = TrainConnector();
52 | ////BoxCSG boxObject = new BoxCSG(20, 20, 20, "base box");
53 | //CsgObject csgObject = new Box(new Vector3(1, 1, 14), "test");
54 | //if (renderRayTrace)
55 | //{
56 | // var matterCadGuiWidget = new MatterCadGuiWidget();
57 | // // AddChild(csgObject);
58 | // // AddChild(new MyGuiWidget());
59 | // matterCadGuiWidget.AnchorAll();
60 | // AnchorAll();
61 | //}
62 |
63 | if (renderRayTrace)
64 | {
65 | matterCadGuiWidget = new MatterCadGuiWidget();
66 | AddChild(matterCadGuiWidget);
67 | matterCadGuiWidget.AnchorAll();
68 | AnchorAll();
69 | }
70 | }
71 |
72 | //public override void OnDraw(Graphics2D graphics2D)
73 | //{
74 | // RoundedRect roundRect = new RoundedRect(new RectangleDouble(Width / 2 - Width / 3 - 1, Height / 2 - Height / 8, Width / 2 + Width / 3 - 1, Height / 2 + Height / 8), 2);
75 |
76 | // graphics2D.Circle(new Vector2(Width / 2, Height / 2), Width / 4 + Height / 4, new RGBA_Bytes(0, 0, 0));
77 |
78 | // var csgObject = new Box(new Vector3(1, 1, 1), "test");
79 | // graphics2D.Render(roundRect, RGBA_Bytes.Pink);
80 | // graphics2D.Line(new Vector2(0, 0), new Vector2(100, 100), new RGBA_Bytes(125, 125, 152));
81 |
82 | // base.OnDraw(graphics2D);
83 | //}
84 | }
85 | public class MatterCadGuiWidget : GuiWidget
86 | {
87 | GuiWidget objectEditorView;
88 | public MatterCadGuiWidget()
89 | {
90 | SuspendLayout();
91 | BackgroundColor = RGBA_Bytes.Blue;
92 | objectEditorView = new TextEditWidget("test", 300, 500)
93 | {
94 | HAnchor = HAnchor.ParentLeftRight,
95 | // textEdit.MinimumSize = new Vector2(Math.Max(textEdit.MinimumSize.x, pixelWidth), Math.Max(textEdit.MinimumSize.y, pixelHeight));
96 | VAnchor = VAnchor.ParentBottomTop,
97 | // BackgroundColor = RGBA_Bytes.Red,
98 | Text = "Hello World!",
99 | Multiline = true
100 | };
101 | ResumeLayout();
102 | AnchorAll();
103 | AddChild(objectEditorView);
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/WindowTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("WindowTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("WindowTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("01409ca3-5caf-4e1b-8541-c8bd604bed58")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/WindowTest/WindowTest.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {01409CA3-5CAF-4E1B-8541-C8BD604BED58}
8 | Exe
9 | WindowTest
10 | WindowTest
11 | v4.8
12 | 512
13 | true
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}
49 | Agg
50 |
51 |
52 | {9b062971-a88e-4a3d-b3c9-12b78d15fa66}
53 | clipper_library
54 |
55 |
56 | {7E61A5BD-E78F-4B80-88C9-3821B4FA062E}
57 | Csg
58 |
59 |
60 | {94838988-523c-4b11-ad82-8b9b76f23a31}
61 | DataConverters2D
62 |
63 |
64 | {74F6BB6C-9D02-4512-A59A-21940E35C532}
65 | Gui
66 |
67 |
68 | {670bddff-927b-425d-9dd1-22acb14356eb}
69 | PlatformWin32
70 |
71 |
72 | {86f6aaf2-9b50-40b8-a427-1897d76471c5}
73 | PolygonMesh
74 |
75 |
76 | {545b6912-77ff-4b34-ba76-6c3d6a32be6a}
77 | RenderOpenGl
78 |
79 |
80 | {ae37de1f-22f7-49ee-8732-fc6bc8dc58d9}
81 | Tesselate
82 |
83 |
84 | {d3e41b4e-bfbb-44ca-94c8-95c00f754fdd}
85 | VectorMath
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------