-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
244 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.28729.10 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "STLAutomationTopSolid", "STLAutomationTopSolid\STLAutomationTopSolid.csproj", "{4E50815A-3113-4A7C-B902-C17F4EBA6153}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{4E50815A-3113-4A7C-B902-C17F4EBA6153}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{4E50815A-3113-4A7C-B902-C17F4EBA6153}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{4E50815A-3113-4A7C-B902-C17F4EBA6153}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{4E50815A-3113-4A7C-B902-C17F4EBA6153}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {3EC846FF-9B65-4396-BA01-B04E1EF5B373} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<configSections> | ||
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" > | ||
<section name="STLAutomationTopSolid.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
<appSettings> | ||
<add key="Chemin" value ="D:\Programmes\Utilitaires\PrusaSlicer\PrusaSlicer\prusa-slicer.exe"/> | ||
</appSettings> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using TopSolid.Kernel.Automating; | ||
using TopSolid.Cad.Design.Automating; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Configuration; | ||
|
||
namespace STLAutomationTopSolid | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
TopSolidHost.Connect(); | ||
TopSolidDesignHost.Connect(); | ||
|
||
//TopSolidDesignHost.Connect(); | ||
|
||
if (!TopSolidHost.IsConnected) | ||
{ | ||
string message = "Could not connect to TopSolid"; | ||
MessageBoxButtons buttons = MessageBoxButtons.OK; | ||
MessageBox.Show(message, "Error", buttons); | ||
return; | ||
} | ||
DocumentId currentDoc = TopSolidHost.Documents.EditedDocument; | ||
|
||
|
||
if(!TopSolidDesignHost.IsConnected) | ||
{ | ||
string message = "Could not connect to TopSolid"; | ||
MessageBoxButtons buttons = MessageBoxButtons.OK; | ||
MessageBox.Show(message, "Error", buttons); | ||
return; | ||
} | ||
|
||
if (!TopSolid.Cad.Design.Automating.TopSolidDesignHost.Parts.IsPart(currentDoc)) | ||
{ | ||
string message = "Only part can be exported."; | ||
MessageBoxButtons buttons = MessageBoxButtons.OK; | ||
MessageBox.Show(message, "Error", buttons); | ||
return; | ||
} | ||
|
||
//get shapes in document | ||
|
||
string currentDocName = TopSolidHost.Documents.GetName(currentDoc); | ||
|
||
string invalid = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars()); | ||
|
||
foreach (char c in invalid) | ||
{ | ||
currentDocName = currentDocName.Replace(c.ToString(), ""); | ||
} | ||
|
||
currentDocName = currentDocName.Replace(" ",""); | ||
|
||
|
||
|
||
|
||
string tempPath = System.IO.Path.GetTempPath(); | ||
|
||
|
||
//search the stl exporter index | ||
|
||
int stlExporterIndex = -1; | ||
for (int i = 0; i < TopSolidHost.Application.ExporterCount; i++) | ||
{ | ||
TopSolidHost.Application.GetExporterFileType(i, out string fileTypeName, out string[] outFileExtensions); | ||
if (fileTypeName != "STL" ) { continue; } | ||
|
||
else | ||
{ | ||
stlExporterIndex = i; | ||
break; | ||
} | ||
} | ||
|
||
|
||
|
||
string exportPath = tempPath + currentDocName +".stl"; | ||
TopSolidHost.Documents.Export(stlExporterIndex, currentDoc, exportPath); | ||
string configuredPath = ConfigurationManager.AppSettings["Chemin"]; | ||
|
||
|
||
|
||
//open slicer wih extracted file | ||
ProcessStartInfo startInfo = new ProcessStartInfo(); | ||
startInfo.FileName = @configuredPath; | ||
startInfo.Arguments = exportPath; | ||
Process.Start(startInfo); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// Les informations générales relatives à un assembly dépendent de | ||
// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations | ||
// associées à un assembly. | ||
[assembly: AssemblyTitle("STLAutomationTopSolid")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("STLAutomationTopSolid")] | ||
[assembly: AssemblyCopyright("Copyright © 2022")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly | ||
// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de | ||
// COM, affectez la valeur true à l'attribut ComVisible sur ce type. | ||
[assembly: ComVisible(false)] | ||
|
||
// Le GUID suivant est pour l'ID de la typelib si ce projet est exposé à COM | ||
[assembly: Guid("4e50815a-3113-4a7c-b902-c17f4eba6153")] | ||
|
||
// Les informations de version pour un assembly se composent des quatre valeurs suivantes : | ||
// | ||
// Version principale | ||
// Version secondaire | ||
// Numéro de build | ||
// Révision | ||
// | ||
// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut | ||
// en utilisant '*', comme indiqué ci-dessous : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{4E50815A-3113-4A7C-B902-C17F4EBA6153}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>STLAutomationTopSolid</RootNamespace> | ||
<AssemblyName>STLAutomationTopSolid</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>..\..\..\..\..\..\Program Files\TOPSOLID\TopSolid 7.17\bin\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>C:\Program Files\TOPSOLID\TopSolid 7.16\bin\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<ApplicationIcon>PrusaSlicer-gcodeviewer.ico</ApplicationIcon> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Configuration" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="TopSolid.Cad.Design.Automating"> | ||
<HintPath>C:\Program Files\TOPSOLID\TopSolid 7.17\bin\TopSolid.Cad.Design.Automating.dll</HintPath> | ||
</Reference> | ||
<Reference Include="TopSolid.Cad.Drafting.Automating"> | ||
<HintPath>C:\Program Files\TOPSOLID\TopSolid 7.17\bin\TopSolid.Cad.Drafting.Automating.dll</HintPath> | ||
</Reference> | ||
<Reference Include="TopSolid.Kernel.Automating"> | ||
<HintPath>C:\Program Files\TOPSOLID\TopSolid 7.17\bin\TopSolid.Kernel.Automating.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="PrusaSlicer-gcodeviewer.ico" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |