Projekt neu angelegt.

This commit is contained in:
Eugen Höglinger 2020-02-27 15:07:57 +01:00
commit d819702522
6 changed files with 557 additions and 0 deletions

32
.gitignore vendored Normal file
View 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/

23
NX_Blech.sln Normal file
View 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", "NX_Blech\NX_Blech.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

209
NX_Blech/EditExpressions.cs Normal file
View File

@ -0,0 +1,209 @@
using System;
using NXOpen;
using NXOpen.UF;
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()
{
//Korrektur wenn das Blech vor NX12 konstruiert wurde
//TODO: Abfrage ob notwendig
PreNX12Created();
//Werte setzen/aktualisieren
UpdateExpressions();
}
private void PreNX12Created()
{
//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(); //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(); //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()
{
//Expression Werte importieren
ImportExpressionValues();
//Den Wert Sheet_Metal_Relief_Width setzen
SetReliefWidth();
//Den Wert Sheet_Metal_Relief_Depth setzen
SetReliefDepth();
//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 SetReliefDepth()
{
//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("MilliMeter");
theSession.Parts.Work.Expressions.EditWithUnits(expression, unit, "0");
}
private void SetReliefWidth()
{
//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("MilliMeter");
theSession.Parts.Work.Expressions.EditWithUnits(expression, unit, ReliefWidth());
}
private string ReliefWidth()
{
Expression thickness = theSession.Parts.Work.Expressions.FindObject("Sheet_Metal_Material_Thickness");
//Der Wert 'reliefWidth' ist abhängig von der Materialstärke
if (thickness.Value >= 6)
{
return "2";
}
else
{
return "1";
}
}
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
}
}

72
NX_Blech/NX_Blech.csproj Normal file
View File

@ -0,0 +1,72 @@
<?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</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>
<ItemGroup>
<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="System" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Content Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<Compile Include="EditExpressions.cs" />
<Compile Include="Program.cs" />
</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>

118
NX_Blech/Program.cs Normal file
View File

@ -0,0 +1,118 @@
using System;
using NXOpen;
using NXOpen.UF;
using NX_Blech;
public class Program
{
// 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()
{
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/ReadMe.txt Normal file
View 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