Projekt neu angelegt.
This commit is contained in:
commit
15b7484adf
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
#Ignore thumbnails created by Windows
|
||||
Thumbs.db
|
||||
#Ignore files built by Visual Studio
|
||||
*.obj
|
||||
*.exe
|
||||
*.pdb
|
||||
*.user
|
||||
*.aps
|
||||
*.pch
|
||||
*.vspscc
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ncb
|
||||
*.suo
|
||||
*.tlb
|
||||
*.tlh
|
||||
*.bak
|
||||
*.cache
|
||||
*.ilk
|
||||
*.log
|
||||
[Bb]in
|
||||
[Dd]ebug*/
|
||||
*.lib
|
||||
*.sbr
|
||||
obj/
|
||||
[Rr]elease*/
|
||||
_ReSharper*/
|
||||
[Tt]est[Rr]esult*
|
||||
.vs/
|
||||
#Nuget packages folder
|
||||
packages/
|
||||
BIN
Daten/Blechparameter.ico
Normal file
BIN
Daten/Blechparameter.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
BIN
Daten/Blechparameter.png
Normal file
BIN
Daten/Blechparameter.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
BIN
Daten/Blechstaerke_Relief.xlsx
Normal file
BIN
Daten/Blechstaerke_Relief.xlsx
Normal file
Binary file not shown.
23
NX_Blech_EPPlus.sln
Normal file
23
NX_Blech_EPPlus.sln
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.572
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NX_Blech_EPPlus", "NX_Blech_EPPlus\NX_Blech_EPPlus.csproj", "{8A8F353E-1761-446E-B11A-BDABD9A7851C}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{8A8F353E-1761-446E-B11A-BDABD9A7851C}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{8A8F353E-1761-446E-B11A-BDABD9A7851C}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {67E631DC-0741-4DF7-9EE9-F64BB165ADFA}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
BIN
NX_Blech_EPPlus/Blechparameter.ico
Normal file
BIN
NX_Blech_EPPlus/Blechparameter.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
341
NX_Blech_EPPlus/EditExpressions.cs
Normal file
341
NX_Blech_EPPlus/EditExpressions.cs
Normal file
@ -0,0 +1,341 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using NXOpen;
|
||||
using NXOpen.UF;
|
||||
using OfficeOpenXml;
|
||||
|
||||
namespace NX_Blech
|
||||
{
|
||||
class EditExpressions
|
||||
{
|
||||
Session theSession = NXOpen.Session.GetSession();
|
||||
|
||||
public EditExpressions()
|
||||
{
|
||||
Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit_Expressions");
|
||||
theSession.SetUndoMarkName(markId1, "Edit_Expression");
|
||||
|
||||
if (Edit())
|
||||
{
|
||||
theSession.DeleteUndoMark(markId1, "Edit_Expressions");
|
||||
}
|
||||
}
|
||||
|
||||
#region OwnMethodes
|
||||
private bool Edit()
|
||||
{
|
||||
if (ThicknessValueExist())
|
||||
{
|
||||
//Aktualisieren
|
||||
CorrectExpressions();
|
||||
|
||||
return false; //Kein Abbruch
|
||||
}
|
||||
else
|
||||
{
|
||||
//Wenn 'Sheet_Metal_Material_Thickness' nicht existiert, dann eine Meldung ausgeben, dass zuerst die Funktion
|
||||
//'Material Blechbearbeitung' ausgeführt werden muss, damit die notwendigen Expression Werte angelegt werden
|
||||
NoThicknessMessage();
|
||||
|
||||
return true; //Abbruch
|
||||
}
|
||||
}
|
||||
|
||||
private bool ThicknessValueExist()
|
||||
{
|
||||
bool thicknessValueExist = false;
|
||||
|
||||
foreach (Expression name in theSession.Parts.Work.Expressions)
|
||||
{
|
||||
if (name.Name == "Sheet_Metal_Material_Thickness")
|
||||
{
|
||||
thicknessValueExist = true;
|
||||
}
|
||||
}
|
||||
|
||||
return thicknessValueExist;
|
||||
}
|
||||
|
||||
private void CorrectExpressions()
|
||||
{
|
||||
//Werte aus Excel tabelle holen
|
||||
string excel = String.Concat(theSession.GetEnvironmentVariableValue("NX_SERVER_DIR"), "\\global\\06_ENGEL_NX_CUSTOMIZING\\Blech\\Blechstaerke_Relief_Eugen.xlsx");
|
||||
string[] sheetMetalValues = new string[5];
|
||||
sheetMetalValues = ReadRow(excel, ReadThickness());
|
||||
string exprUnit = "MilliMeter";
|
||||
|
||||
//Korrektur wenn das Blech vor NX12 konstruiert wurde
|
||||
//TODO: Abfrage ob notwendig
|
||||
PreNX12Created(exprUnit, sheetMetalValues);
|
||||
|
||||
//Werte setzen/aktualisieren
|
||||
UpdateExpressions(exprUnit, sheetMetalValues);
|
||||
}
|
||||
|
||||
private void PreNX12Created(string exprUnit, string[] sheetMetalValues)
|
||||
{
|
||||
//Korrektur wenn das Blech vor NX12 konstruiert wurde
|
||||
foreach (Expression name in theSession.Parts.Work.Expressions)
|
||||
{
|
||||
//Existiert der Wert 't', dann den Wert 'Sheet_Metal_Relief_Depth' auf '0' setzen und den Wert 't' löschen
|
||||
if (name.Name == "t")
|
||||
{
|
||||
SetReliefDepth(exprUnit, sheetMetalValues[2]); //Den Wert Sheet_Metal_Relief_Depth auf 0 setzen
|
||||
ChangeValue("t", "Sheet_Metal_Relief_Depth"); //Alle Expressions die den Wert 't' enthalten gegen den Wert 'Sheet_Metal_Relief_Depth' tauschen
|
||||
DeleteExpression("t"); //Expression 't' löschen
|
||||
}
|
||||
|
||||
//Existiert der Wert 'b', dann den Wert 'Sheet_Metal_Relief_Width' abhängig vom Wert 'Sheet_Metal_Material_Thickness' auf '1' oder '2' setzen und den Wert 'b' löschen
|
||||
if (name.Name == "b")
|
||||
{
|
||||
SetReliefWidth(exprUnit, sheetMetalValues[1]); //Den Wert 'Sheet_Metal_Relief_Width' abhängig von der Materialstärke auf '1' oder '2' setzen
|
||||
ChangeValue("b", "Sheet_Metal_Relief_Width"); //Alle Expressions die den Wert 'b' enthalten gegen den Wert 'Sheet_Metal_Relief_Width' tauschen
|
||||
DeleteExpression("b"); //Expression 'b' löschen
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateExpressions(string exprUnit, string[] sheetMetalValues)
|
||||
{
|
||||
//Expression Werte setzen
|
||||
SetExpressionValues(exprUnit, sheetMetalValues);
|
||||
|
||||
//Den Wert Sheet_Metal_Relief_Width setzen
|
||||
SetReliefWidth(exprUnit, sheetMetalValues[1]);
|
||||
|
||||
//Den Wert Sheet_Metal_Relief_Depth setzen
|
||||
SetReliefDepth(exprUnit, sheetMetalValues[2]);
|
||||
|
||||
//k-Faktor bei 10mm Blech von 0.28 auf 0.42 ändern
|
||||
CorrectKFactor();
|
||||
}
|
||||
|
||||
//private void ImportExpressionValues()
|
||||
//{
|
||||
// //Dateiname der Blech-Expression-Tabelle
|
||||
// string sheetMetalExpressionValues = String.Concat(theSession.GetEnvironmentVariableValue("NX_SERVER_DIR"), "\\global\\06_ENGEL_NX_CUSTOMIZING\\Blech\\blech.exp");
|
||||
|
||||
// //Expression Werte importieren
|
||||
// bool expModified;
|
||||
// string[] errorMessages = new string[50];
|
||||
// theSession.Parts.Work.Expressions.ImportFromFile(sheetMetalExpressionValues, ExpressionCollection.ImportMode.Replace, out expModified, out errorMessages);
|
||||
//}
|
||||
|
||||
private void SetExpressionValues(string exprUnit, string[] sheetMetalValues)
|
||||
{
|
||||
//Wert 's' setzen
|
||||
SetUnitlessExpressionValue("s", exprUnit, "format( \"%#2.1f\", Sheet_Metal_Material_Thickness, \"units\", \"unitless\" )");
|
||||
|
||||
//Wert 'db' setzen
|
||||
SetExpressionValue("db", exprUnit, sheetMetalValues[3]);
|
||||
|
||||
//Wert 'o' setzen
|
||||
SetExpressionValue("o", exprUnit, sheetMetalValues[4]);
|
||||
}
|
||||
|
||||
private string[] ReadRow(string excel, string sheetMetalThickness)
|
||||
{
|
||||
string[] sheetMetalValues = new string[5];
|
||||
|
||||
try
|
||||
{
|
||||
var fi = new FileInfo(excel);
|
||||
|
||||
using (var p = new ExcelPackage(fi))
|
||||
{
|
||||
//Get the Worksheet created in the previous codesample.
|
||||
var ws = p.Workbook.Worksheets["Werte"];
|
||||
|
||||
for (int i = 1; i <= ws.Dimension.End.Row; i++)
|
||||
{
|
||||
if (ws.Cells[i, 1].Value != null)
|
||||
{
|
||||
if (ws.Cells[i, 1].Value.ToString() == sheetMetalThickness)
|
||||
{
|
||||
sheetMetalValues[0] = ws.Cells[i, 1].Value.ToString();
|
||||
sheetMetalValues[1] = ws.Cells[i, 2].Value.ToString();
|
||||
sheetMetalValues[2] = ws.Cells[i, 3].Value.ToString();
|
||||
sheetMetalValues[3] = ws.Cells[i, 4].Value.ToString();
|
||||
sheetMetalValues[4] = ws.Cells[i, 5].Value.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("Fehler");
|
||||
}
|
||||
return sheetMetalValues;
|
||||
}
|
||||
|
||||
private string ReadThickness()
|
||||
{
|
||||
Expression thickness = theSession.Parts.Work.Expressions.FindObject("Sheet_Metal_Material_Thickness");
|
||||
|
||||
return thickness.Value.ToString(); //Gibt die Materialstärke zurück
|
||||
}
|
||||
|
||||
private void SetUnitlessExpressionValue(string exprName, string exprUnit, string exprValue)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
foreach (Expression name in theSession.Parts.Work.Expressions)
|
||||
{
|
||||
if (name.Name == exprName)
|
||||
{
|
||||
//Einen Expression Wert setzen
|
||||
Expression expression = theSession.Parts.Work.Expressions.FindObject(name.Name);
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject(exprUnit);
|
||||
|
||||
theSession.Parts.Work.Expressions.Edit(expression, exprValue);
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Wenn die Expression noch nicht existiert, dann erzeugen
|
||||
if (!found)
|
||||
{
|
||||
CreateUnitlessExpressionValue(exprName, exprUnit, exprValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetExpressionValue(string exprName, string exprUnit, string exprValue)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
foreach (Expression name in theSession.Parts.Work.Expressions)
|
||||
{
|
||||
if (name.Name == exprName)
|
||||
{
|
||||
//Einen Expression Wert setzen
|
||||
Expression expression = theSession.Parts.Work.Expressions.FindObject(name.Name);
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject(exprUnit);
|
||||
Unit nullNXOpen_Unit = null;
|
||||
theSession.Parts.Work.Expressions.EditWithUnits(expression, nullNXOpen_Unit, SetCommaToDot(exprValue));
|
||||
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Wenn die Expression noch nicht existiert, dann erzeugen
|
||||
if (!found)
|
||||
{
|
||||
CreateExpressionValue(exprName, exprUnit, exprValue);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateUnitlessExpressionValue(string exprName, string exprUnit, string exprValue)
|
||||
{
|
||||
//Einen Expression Wert erzeugen
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject(exprUnit);
|
||||
Expression expression;
|
||||
string expr = String.Concat(exprName, "=", exprValue);
|
||||
expression = theSession.Parts.Work.Expressions.CreateExpression("String", expr);
|
||||
}
|
||||
|
||||
private void CreateExpressionValue(string exprName, string exprUnit, string exprValue)
|
||||
{
|
||||
//Einen Expression Wert erzeugen
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject(exprUnit);
|
||||
Expression expression;
|
||||
string expr = String.Concat(exprName, "=", SetCommaToDot(exprValue));
|
||||
expression = theSession.Parts.Work.Expressions.CreateWithUnits(expr, unit);
|
||||
}
|
||||
|
||||
private string SetCommaToDot(string exprValue)
|
||||
{
|
||||
//Sicherstellen, dass das Komma ein Punkt ist
|
||||
try
|
||||
{
|
||||
double result = 0.0;
|
||||
if (Double.TryParse(exprValue, out result))
|
||||
{
|
||||
exprValue = Convert.ToDouble(exprValue).ToString(System.Globalization.CultureInfo.CreateSpecificCulture("en-us")); ;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{ }
|
||||
|
||||
return exprValue;
|
||||
}
|
||||
|
||||
private void SetReliefDepth(string exprUnit, string sheetMetalValues)
|
||||
{
|
||||
//Den Wert Sheet_Metal_Relief_Depth auf 0 setzen
|
||||
Expression expression = theSession.Parts.Work.Expressions.FindObject("Sheet_Metal_Relief_Depth");
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject(exprUnit);
|
||||
|
||||
theSession.Parts.Work.Expressions.EditWithUnits(expression, unit, sheetMetalValues);
|
||||
}
|
||||
|
||||
private void SetReliefWidth(string exprUnit, string sheetMetalValues)
|
||||
{
|
||||
//Den Wert Sheet_Metal_Relief_Width abhängig von der Materialstärke auf 1 oder 2 setzen
|
||||
Expression expression = theSession.Parts.Work.Expressions.FindObject("Sheet_Metal_Relief_Width");
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject(exprUnit);
|
||||
|
||||
theSession.Parts.Work.Expressions.EditWithUnits(expression, unit, sheetMetalValues);
|
||||
}
|
||||
|
||||
private void CorrectKFactor()
|
||||
{
|
||||
foreach (Expression name in theSession.Parts.Work.Expressions)
|
||||
{
|
||||
if (name.Name == "Sheet_Metal_Material_Thickness")
|
||||
{
|
||||
Expression thickness = theSession.Parts.Work.Expressions.FindObject("Sheet_Metal_Material_Thickness");
|
||||
|
||||
if (thickness.Value == 10)
|
||||
{
|
||||
//Wenn die Blechdicke 10mm ist, dann den Wert 'Sheet_Metal_Neutral_Factor' von '0.28' auf '0.42' setzen
|
||||
Expression expression = theSession.Parts.Work.Expressions.FindObject("Sheet_Metal_Neutral_Factor");
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject("MilliMeter");
|
||||
string kFactor = "0.42";
|
||||
|
||||
theSession.Parts.Work.Expressions.EditWithUnits(expression, unit, kFactor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeValue(string value, string newValue)
|
||||
{
|
||||
//Alle Expressions die den Wert 'value' enthalten gegen den Wert 'newValue' tauschen
|
||||
foreach (Expression name in theSession.Parts.Work.Expressions)
|
||||
{
|
||||
if (name.RightHandSide == value)
|
||||
{
|
||||
Expression expression = theSession.Parts.Work.Expressions.FindObject(name.Name);
|
||||
Unit unit = theSession.Parts.Work.UnitCollection.FindObject("MilliMeter");
|
||||
theSession.Parts.Work.Expressions.EditWithUnits(expression, unit, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DeleteExpression(string value)
|
||||
{
|
||||
//Expression löschen
|
||||
Expression expression = theSession.Parts.Work.Expressions.FindObject(value);
|
||||
|
||||
theSession.Parts.Work.Expressions.Delete(expression);
|
||||
}
|
||||
|
||||
private void NoThicknessMessage()
|
||||
{
|
||||
if (theSession.GetEnvironmentVariableValue("UGII_LANG") == "german")
|
||||
{
|
||||
//deutsch
|
||||
NXOpen.UI.GetUI().NXMessageBox.Show("Warnung!", NXMessageBox.DialogType.Warning, "Bitte zuerst die Funktion \"Material Blechbearbeitung\"\nund dann noch einmal \"ENGEL_Blechparameter\" ausführen!");
|
||||
}
|
||||
else
|
||||
{
|
||||
//englisch
|
||||
NXOpen.UI.GetUI().NXMessageBox.Show("Warning!", NXMessageBox.DialogType.Warning, "Please execute the function \"Material Blechbearbeitung\"\nfirst and then \"ENGEL_Blechparameter\" again!");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
87
NX_Blech_EPPlus/NX_Blech_EPPlus.csproj
Normal file
87
NX_Blech_EPPlus/NX_Blech_EPPlus.csproj
Normal file
@ -0,0 +1,87 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x64</Platform>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>NX_Blech_EPPlus</RootNamespace>
|
||||
<AssemblyName>$(PROJECT_NAME)</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||
<ProjectGuid>{8A8F353E-1761-446E-B11A-BDABD9A7851C}</ProjectGuid>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>Blechparameter.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="EPPlus, Version=4.5.3.1, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\EPPlus.4.5.3.1\lib\net40\EPPlus.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NXOpen, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(UGII_BASE_DIR)\nxbin\managed\NXOpen.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="NXOpen.UF, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(UGII_BASE_DIR)\nxbin\managed\NXOpen.UF.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="NXOpen.Utilities, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(UGII_BASE_DIR)\nxbin\managed\NXOpen.Utilities.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="NXOpenUI, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>$(UGII_BASE_DIR)\nxbin\managed\NXOpenUI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Blechparameter.ico" />
|
||||
<Content Include="ReadMe.txt" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="EditExpressions.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
164
NX_Blech_EPPlus/Program.cs
Normal file
164
NX_Blech_EPPlus/Program.cs
Normal file
@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using NXOpen;
|
||||
using NXOpen.UF;
|
||||
using NX_Blech;
|
||||
|
||||
public class Program
|
||||
{
|
||||
#region Version und Copyright
|
||||
// Version und Copyright
|
||||
string programName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); //Den Programmnamen auslesen
|
||||
string programVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
string copyright = "Copyright © 2018 by Eugen Höglinger";
|
||||
//Assembly Datum und Zeit
|
||||
static DateTime value = AssemblyDateTime();
|
||||
string date = value.ToShortDateString();
|
||||
string time = value.ToLongTimeString();
|
||||
private static DateTime AssemblyDateTime()
|
||||
{
|
||||
var version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
|
||||
var buildDateTime = new DateTime(2000, 1, 1).Add(new TimeSpan(TimeSpan.TicksPerDay * version.Build + TimeSpan.TicksPerSecond * 2 * version.Revision));
|
||||
//Tage seit dem 1. Januar 2000 und Sekunden seit Mitternacht, (multiplizier mit 2 ergibt das Original)
|
||||
return buildDateTime;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Programm-Info
|
||||
/// <summary>
|
||||
/// Contains the name of the program file
|
||||
/// </summary>
|
||||
public static string ProgramName { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the version of the program file
|
||||
/// </summary>
|
||||
public static string ProgramVersion { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// Contains the copyright notice
|
||||
/// </summary>
|
||||
public static string Copyright { set; get; }
|
||||
|
||||
private void SetProgramInfo()
|
||||
{
|
||||
//Name, Version und Copyright setzen
|
||||
ProgramName = programName;
|
||||
ProgramVersion = programVersion;
|
||||
Copyright = copyright;
|
||||
}
|
||||
#endregion
|
||||
|
||||
// class members
|
||||
private static Session theSession;
|
||||
private static UI theUI;
|
||||
private static UFSession theUfSession;
|
||||
public static Program theProgram;
|
||||
public static bool isDisposeCalled;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Constructor
|
||||
//------------------------------------------------------------------------------
|
||||
public Program()
|
||||
{
|
||||
SetProgramInfo(); //Stellt die Programm Info bereit
|
||||
|
||||
try
|
||||
{
|
||||
theSession = Session.GetSession();
|
||||
theUI = UI.GetUI();
|
||||
theUfSession = UFSession.GetUFSession();
|
||||
isDisposeCalled = false;
|
||||
}
|
||||
catch (NXOpen.NXException ex)
|
||||
{
|
||||
// ---- Enter your exception handling code here -----
|
||||
// UI.GetUI().NXMessageBox.Show("Message", NXMessageBox.DialogType.Error, ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool FirstLoop { set; get; }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Explicit Activation
|
||||
// This entry point is used to activate the application explicitly
|
||||
//------------------------------------------------------------------------------
|
||||
public static int Main(string[] args)
|
||||
{
|
||||
FirstLoop = true;
|
||||
|
||||
int retValue = 0;
|
||||
try
|
||||
{
|
||||
theProgram = new Program();
|
||||
|
||||
//TODO: Add your application code here
|
||||
var editExpression = new EditExpressions();
|
||||
|
||||
theProgram.Dispose();
|
||||
}
|
||||
catch (NXOpen.NXException ex)
|
||||
{
|
||||
// ---- Enter your exception handling code here -----
|
||||
|
||||
//Manche Parts erzeugen aus unerklärlichen Gründen beim ersten Durchlauf einen Fehler, in so einem Fall wird ein zweiter Durchlauf versucht.
|
||||
//Verursacht auch der zweite Durchlauf einen Fehler, dann ist die Aufgabe tatsächlich zu komplex und es wird eine Fehlermeldung ausgegeben.
|
||||
if (FirstLoop)
|
||||
{
|
||||
FirstLoop = false; //Wenn schon einmal durchgelaufen, dann setzen
|
||||
var editExpression = new EditExpressions();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowComplexTaskMessage(); //Meldung ausgeben wenn die Aufgabe zu komplex ist.
|
||||
}
|
||||
}
|
||||
return retValue;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Following method disposes all the class members
|
||||
//------------------------------------------------------------------------------
|
||||
public void Dispose()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isDisposeCalled == false)
|
||||
{
|
||||
//TODO: Add your application code here
|
||||
}
|
||||
isDisposeCalled = true;
|
||||
}
|
||||
catch (NXOpen.NXException ex)
|
||||
{
|
||||
// ---- Enter your exception handling code here -----
|
||||
}
|
||||
}
|
||||
|
||||
public static int GetUnloadOption(string arg)
|
||||
{
|
||||
//Unloads the image explicitly, via an unload dialog
|
||||
//return System.Convert.ToInt32(Session.LibraryUnloadOption.Explicitly);
|
||||
|
||||
//Unloads the image immediately after execution within NX
|
||||
// return System.Convert.ToInt32(Session.LibraryUnloadOption.Immediately);
|
||||
|
||||
//Unloads the image when the NX session terminates
|
||||
return System.Convert.ToInt32(Session.LibraryUnloadOption.AtTermination);
|
||||
}
|
||||
|
||||
private static void ShowComplexTaskMessage()
|
||||
{
|
||||
if (theSession.GetEnvironmentVariableValue("UGII_LANG") == "german")
|
||||
{
|
||||
//deutsch
|
||||
NXOpen.UI.GetUI().NXMessageBox.Show("Warnung!", NXMessageBox.DialogType.Warning, "Die geforderte Aufgabe ist zu komplex.\nBitte lösen Sie die Aufgabe manuell.\nUnterstütztung erhalten Sie von ihrem Keyuser.");
|
||||
}
|
||||
else
|
||||
{
|
||||
//englisch
|
||||
NXOpen.UI.GetUI().NXMessageBox.Show("Warning!", NXMessageBox.DialogType.Warning, "The required task is too complex.\nPlease solve the task manually.\nYou will receive support from your keyuser.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
103
NX_Blech_EPPlus/ReadMe.txt
Normal file
103
NX_Blech_EPPlus/ReadMe.txt
Normal file
@ -0,0 +1,103 @@
|
||||
========================================================================
|
||||
NX_OPEN : NX_Blech Project Overview
|
||||
========================================================================
|
||||
|
||||
NX12 Open C# Wizard has created this NX_Blech project for you as a starting point.
|
||||
|
||||
This file contains a summary of what you will find in each of the files that make up your project.
|
||||
|
||||
NX_Blech.vbproj
|
||||
This is the main project file for projects generated using an Application Wizard.
|
||||
It contains information about the version of the product that generated the file, and
|
||||
information about the platforms, configurations, and project features selected with the
|
||||
Application Wizard.
|
||||
|
||||
Executing User Exit Functions
|
||||
-----------------------------
|
||||
|
||||
For execution of each user exit, corresponding Environment Variable need to be set with the full path
|
||||
of the dll.
|
||||
|
||||
The following environment variables are used to point to user exit executables.
|
||||
Alternatively a single Environment Variable USER_DEFAULT can be set for all the Entry point.
|
||||
|
||||
User Exit Environment Variable Entry Point
|
||||
|
||||
Open Part USER_RETRIEVE ufget
|
||||
|
||||
New Part USER_CREATE ufcre
|
||||
|
||||
Save Part USER_FILE ufput
|
||||
|
||||
Save Part As USER_SAVEAS ufsvas
|
||||
|
||||
Import Part USER_MERGE ufmrg
|
||||
|
||||
Execute GRIP Program USER_GRIP ufgrp
|
||||
|
||||
Add Existing Part USER_RCOMP ufrcp
|
||||
|
||||
Export Part USER_FCOMP uffcp
|
||||
|
||||
Component Where-used USER_WHERE_USED ufusd
|
||||
|
||||
Plot File USER_PLOT ufplt
|
||||
|
||||
2D Analysis Using
|
||||
Curves USER_AREAPROPCRV uf2da
|
||||
|
||||
User Defined Symbols USER_UDSYMBOL ufuds
|
||||
|
||||
Open CLSF USER_CLS_OPEN ufclso
|
||||
|
||||
Save CLSF USER_CLS_SAVE ufclss
|
||||
|
||||
Rename CLSF USER_CLS_RENAME ufclsr
|
||||
|
||||
Generate CLF USER_CL_GEN ufclg
|
||||
|
||||
Postprocess CLSF USER_POST ufpost
|
||||
|
||||
Create Component USER_CCOMP ufccp
|
||||
|
||||
Change Displayed Part USER_CDISP ufcdp
|
||||
|
||||
Change Work Part USER_CWORK ufcwp
|
||||
|
||||
Remove Component USER_DCOMP ufdcp
|
||||
|
||||
Reposition Component USER_MCOMP ufmcp
|
||||
|
||||
Substitute Component
|
||||
Out USER_SCOMP1 ufscpo
|
||||
|
||||
Substitute Component In USER_SCOMP2 ufscpi
|
||||
|
||||
Open Spreadsheet USER_SPRD_OPN ufspop
|
||||
|
||||
Close Spreadsheet USER_SPRD_CLO ufspcl
|
||||
|
||||
Update Spreadsheet USER_SPRD_UPD ufspup
|
||||
|
||||
Finish Updating
|
||||
Spreadsheet USER_SPRD_UPF ufspuf
|
||||
|
||||
Replace Reference Set USER_RRSET ufrrs
|
||||
|
||||
Rename Component USER_NCOMP ufncp
|
||||
|
||||
NX Startup USER_STARTUP ufsta
|
||||
|
||||
Access Genius Library
|
||||
Management System USER_GENIUS ufgen
|
||||
|
||||
Execute Debug GRIP USER_GRIPDEBUG ufgrpd
|
||||
|
||||
Execute User Function USER_UFUN ufufun
|
||||
|
||||
Initialize new operation
|
||||
Re-initialize an
|
||||
existing operation USER_CREATE_OPER ufnopr
|
||||
|
||||
CAM Startup USER_CAM_STARTUP ufcams
|
||||
|
||||
4
NX_Blech_EPPlus/packages.config
Normal file
4
NX_Blech_EPPlus/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="EPPlus" version="4.5.3.1" targetFramework="net46" />
|
||||
</packages>
|
||||
Loading…
Reference in New Issue
Block a user