大家好,欢迎来到IT知识分享网。
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
本文主要记录了一些EKL脚本语言的基础代码示例。
一、什么是EKL?
二、练习案例
1.创建物理产品和3D Part
代码如下:
let productRef(VPMReference) productRef = new("VPMReference","myProductRef",NULL) let productIns(VPMInstance) productIns = new("VPMInstance","myProductIns",rootProduct,productRef) Let createdInstance1(VPMInstance) createdInstance1 = new("3DPart", "MyNewRef3DPart",productRef)
2.遍历查询
代码如下:
Let childrenList1,childrenList2,childrenList3,childrenList4,childrenList5(List) childrenList1 = ProductOcc.Children //Message("No of Children = ", childrenList1.Size()) Notify("list",childrenList1) childrenList2=ProductOcc.Reference.Query("AdvisorAction","") Notify("list",childrenList2) childrenList3=ProductOcc.Reference.Query("VPMReference","") Notify("list",childrenList3) childrenList4=ProductOcc.Query("ProductOccurrence","x.Name==\"MyNewRef3DPart.2\"") Notify("list",childrenList4) childrenList5=ProductOcc.Query("ProductOccurrence","x.Name like\"*MyNewRef3DPart*\"") Notify("list",childrenList5)
3.创建几何图形集
代码如下:(这里有一个问题,3D Shape的节点是PartFeature类型,但是选择的时候却不能选择3D Shape节点,而是选择了其下面的特征节点)
let createdOpenBodyFeature(OpenBodyFeature) let Body1(BodyFeature) createdOpenBodyFeature=new("OpenBodyFeature","几何图形集",parentRepInstance) Body1=new("BodyFeature","立柱",parentRepInstance,"")
4.文件交互
1、读写excel文件,使用CreateSheet()来打开Excel,如果想要打开具体的页,就用CreateSheet([strFileName]SheetNumber),想要写入Excel,要用SetCell(),读取用CellAsBoolean()、CellAsString()、CellAsReal()。但是要注意,SetCell()的行数计数是从1开始的,而CellAsString()这些都是从0开始计数的。
Let strFileName(String) Let oXLSheet(DTSheetType) Let indx(Integer) Let noOfRows(Integer) Let strColorName(String) Let rValue(Real) Let gValue(Real) Let bValue(Real) Let strRowValue(String) strFileName = "C:\\Users\\Atz\\Desktop\\input.xlsx" Set oXLSheet = CreateSheet(strFileName) noOfRows = oXLSheet.RowsNb//获取行数 indx = 1 oXLSheet.SetCell(6,2,666) Notify(oXLSheet.CellAsString(5, 2)) For indx while indx < noOfRows {
strColorName = oXLSheet.CellAsString(indx, 1) rValue = oXLSheet.CellAsReal(indx, 2) gValue = oXLSheet.CellAsReal(indx, 3) bValue = oXLSheet.CellAsReal(indx, 4) Notify(strColorName," ",rValue," ",gValue," ",bValue) }
2、读写txt文件,OpenTextFile的时候,”r”表示读,”w”表示写,”a”表示在结尾往后写,
Let file (TextFile) Let buffer (String) Set file = OpenTextFile("C:\\Users\\Atz\\Desktop\\input.txt","r") buffer = file->Read() Set file = OpenTextFile("C:\\Users\\Atz\\Desktop\\input2.txt","a") file->Write(buffer) file->Close()
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/140880.html