python连接eplan的api_EPLAN API 入门系列- 基础篇
1、Project::HierarchyEplan::EplApi::DataModel::Project::Hierarchy EnumerationHierarchy level of the device structureC#public enumHierarchy {Functional,Plant,Place,Location,Installation,Document,UserDef
1、Project::Hierarchy
Eplan::EplApi::DataModel::Project::Hierarchy Enumeration
Hierarchy level of the device structure
C#public enumHierarchy {
Functional,
Plant,
Place,
Location,
Installation,
Document,
UserDef
}
End Enum
Members Description
Functional Functional assignment (==)
Plant Higher-level function (=)
Place Installation site (++)
Location Mounting location (+)
Installation Higher level function number
Document Document type (&)
UserDef User-defined (#)2、StorableObject
Eplan::EplApi::DataModel::StorableObject:
The parent of all API classes representing P8 project and its structure.
Eplan::EplApi::DataModel::StorableObject
Eplan::EplApi::DataModel::Article
Eplan::EplApi::DataModel::ArticleReference
Eplan::EplApi::DataModel::CommunicationEntity
Eplan::EplApi::DataModel::Connection
Eplan::EplApi::DataModel::DeviceListEntry
Eplan::EplApi::DataModel::E3D::PlaceHolder3D
Eplan::EplApi::DataModel::E3D::Placement3D
Eplan::EplApi::DataModel::FunctionDefinition
Eplan::EplApi::DataModel::Location
Eplan::EplApi::DataModel::MasterData::FunctionDefinitionLibrary
Eplan::EplApi::DataModel::MasterData::Symbol
Eplan::EplApi::DataModel::MasterData::SymbolLibrary
Eplan::EplApi::DataModel::MergedArticleReference
Eplan::EplApi::DataModel::MergedConnection
Eplan::EplApi::DataModel::MergedFunction
Eplan::EplApi::DataModel::OptionBase
Eplan::EplApi::DataModel::Placement
Eplan::EplApi::DataModel::PlcIO
Eplan::EplApi::DataModel::Project
Eplan::EplApi::DataModel::ReportBlock2.1plan::EplApi::DataModel::Project
Class representing P8 project.2.2Eplan::EplApi::DataModel::Page
Example
The following example shows how to useclassPage.
[C#]private Page Page_Example1(Project oProject, string strProjectPath, stringstrPageName)
{if (oProject == null)
{
ProjectManager oProjManager= newProjectManager();if (oProjManager.CurrentProject == null)
oProject=oProjManager.OpenProject(strProjectPath);elseoProject=oProjManager.CurrentProject;
}
oProject.Filter.Name=strPageName;
PageoProject.Filter.ExactNameMatching= true;
arrPages[]=oProject.Pages;if (arrPages.Length == 0)return null;return arrPages[0];
}2.3Eplan::EplApi::DataModel::Article
Thisclass represents articles inthe Eplan.EplApi.DataModel.Projec.
Example
The following example shows how to useclassArticle.
[C#]private voidArticle_Example1(Project oProject)
{foreach (Article oArticle inoProject.Articles)
{if ("BECK.KL2012" ==oArticle.PartNr)
{if (!oArticle.Properties.ARTICLE_DEPTH.IsEmpty)
WriteMessage("ARTICLE_DEPTH :" +oArticle.Properties.ARTICLE_DEPTH);if (!oArticle.Properties.ARTICLE_VARIANT.IsEmpty)
WriteMessage("ARTICLE_VARIANT :" +oArticle.Properties.ARTICLE_VARIANT);foreach (int nIndex inoArticle.Properties.ARTICLE_FREE_DATA_DESCRIPTION.Indexes)
WriteMessage("ARTICLE_FREE_DATA_DESCRIPTION[" + nIndex + "] :" +oArticle.Properties.ARTICLE_FREE_DATA_DESCRIPTION[nIndex]);foreach (int nIndex inoArticle.Properties.ARTICLE_FREE_DATA_UNIT.Indexes)
WriteMessage("ARTICLE_FREE_DATA_UNIT[" + nIndex + "] :" +oArticle.Properties.ARTICLE_FREE_DATA_UNIT[nIndex]);foreach (int nIndex inoArticle.Properties.ARTICLE_FREE_DATA_VALUE.Indexes)
WriteMessage("ARTICLE_FREE_DATA_VALUE[" + nIndex + "] :" +oArticle.Properties.ARTICLE_FREE_DATA_VALUE[nIndex]);
}
}
}2.2plan::EplApi::DataModel::ArticleReference
Thisclassrepresents a part reference on a project, function, or a connection.
[C#]
Article oArticle= newArticle();
oArticle.Create(oProject,"KUKA.KR30-3", "1"); //empty Article is created in a Project
bool bResult = oArticle.LoadFromMasterdata(); //Article is filled with data from system parts database
oProject.AddArticleReference("KUKA.KR30-3", "1", 1); //reference to the Article is created on a Project
oFunction.AddArticleReference("KUKA.KR30-3", "1", 1); //reference to the Article is created on a Function
oConnection.AddArticleReference("KUKA.KR30-3", "1", 1); //reference to the Article is created on a Connection
2.4Eplan::EplApi::DataModel::Connection
Some properties of Data model classes are not linked with their owners evenif from the syntax it may seem otherwise. Like in this line: oRectangle.Pen.ColorId = 5, the ColorId of the Pen is changed but oRectangle object doesn't know about it since the Pen property is a stand alone value not aware of oRectangle object existence. This remark applies to the following Connection properties: Articles, Shieldings, SubConnections, SymbolReferences, Pins.
2.5Eplan::EplApi::DataModel::Function
Aclass that represents logical devices (or device sub-components) of Eplan.EplApi.DataModel.Project's Eplan.EplApi.DataModel.Page.
Example
The following example shows how to create and place Function on page.
[C#string strSymbolLibName = "DIC_WUPD";string strSymbolName = "MW";int nVariant = 1;//First get SymbolVariant
SymbolLibrary oSymbolLibrary = newSymbolLibrary(oProject, strSymbolLibName);
Symbol oSymbol= newSymbol(oSymbolLibrary, strSymbolName);
SymbolVariant oSymbolVariant= newSymbolVariant();
oSymbolVariant.Initialize(oSymbol, nVariant);//Create Function
Function oNewFunction = newFunction();
oNewFunction.Create(oPage, oSymbolVariant);//Set function name
oNewFunction.Name = "=AP+ST1-M1";
oNewFunction.VisibleName= "M1";//Set pins descriptions
oNewFunction.Properties.FUNC_CONNECTIONDESIGNATION[1] = "1";
oNewFunction.Properties.FUNC_CONNECTIONDESIGNATION[2] = "2";
oNewFunction.Properties.FUNC_CONNECTIONDESIGNATION[3] = "PE";//Set location
oNewFunction.Location = new PointD(120.0, 215.0);
Next example shows how to build connection between two functions.
[C#]string strSymbolLibName = "DIC_WUPD";string strSymbolName = "M3";int nVariant = 0;
SymbolLibrary oSymbolLibrary= newSymbolLibrary(oProject, strSymbolLibName);
Symbol oSymbol= newSymbol(oSymbolLibrary, strSymbolName);
SymbolVariant oSymbolVariant= newSymbolVariant();
oSymbolVariant.Initialize(oSymbol, nVariant);
Function oFunction= newFunction();
oFunction.Create(oPage, oSymbolVariant);
oFunction.Name= "A";
oFunction.Location= new PointD(100, 100);
Function oFunction2= newFunction();
oFunction2.Create(oPage, oSymbolVariant);
oFunction2.Name= "B";
oFunction2.Location= new PointD(100, 50);newEplan.EplApi.HEServices.Generate().Connections(oPage.Project);//oFunction.Pins[3].TargetPins[0].ParentFunction.Name == "=+-B"
2.6Eplan.EplApi.Base.SchemeSetting
Settings
are used to save values of variables beyond the runtime of the program and to
make them available again the next time programisrun (similar to the Windows
registry). A setting has a unique identifierinthe system. A value or a list
of values can be saved to a setting. Itispossible to group settings into
structures Eplan.EplApi.Base.SchemeSetting.
Example
Access to a setting of the systemtry{
String strGuiLanguage= new Settings().GetStringSetting("USER.SYSTEM.GUI.LANGUAGE", 0);
System.Windows.Forms.MessageBox.Show("The user interface language is set to:"+strGuiLanguage);
}catch(BaseException exc)
{
String strMessage=exc.Message;
System.Windows.Forms.MessageBox.Show("Exception:" +strMessage);
}
更多推荐
所有评论(0)