发帖
 找回密码
 立即注册
搜索
1 0 0

createcopy、createinstance、insertcopy的区别

技术交流 1165 1 2019-5-24 12:31:08
共同点:
三个函数的本质都是插入节点。
不同点:
createcopy是复制节点,可以将任意节点复制到任意节点,比如复制暂存区到模型,复制A实体标签至B实体。
createinstance是实例化类,可以将类实例化。
insertcopy是复制临时实体到某个实体之中。

比如要在模型中插入一个暂存区:
如果使用createcopy函数,会将复制对象的颜色、位置、标签、触发等属性完全复制,原暂存区内的临时实体也会完全复制,甚至连名字都可以一模一样,这就是“copy”。
如果使用createinstance,效果等同于从library拖一个暂存区到模型中,在程序中我们称之为“将Queue类实例化”,也就是在模型中创建一个崭新的暂存区对象。
insertcopy无法复制固定实体,只能复制临时实体,并且会激活OnReceive事件和OnEntry触发。

[b]createcopy[/b][align=left]createcopy (node thenode, node container [,num samename, num inobject, num cached, num replace])[/align][align=left]Copies thenode into the specified container[/align][align=left]Description[/align][align=left]Copy thenode into the node specified ascontainer. This command is different from createinstance() in that it does notattempt to establish any links between thenode and any class. If aninstantiation is required, use createinstance() instead. [/align][b]createinstance[/b][align=left]createinstance (obj class, obj location)[/align][align=left]Description[/align][align=left]This command creates an instance of theclass specified as class and places it in the object specified as location. Theinstance will be given a name that is the name of the class followed by anumber. The instance will have all of the variables and attributes of class andit's superclasses. Nodes in the behavior node will not be copied into theinstance, as they apply to all instances of the class. The object passed asclass should be in the library. Generally, location is the model. The libraryand the model can be easily referenced using the library() and model()commands.[/align][align=left][/align][b]insertcopy[/b][align=left]insertcopy (obj originalobject, objcontainerobject)[/align][align=left]Creates a copy of the flowitem and moves itinto the container object[/align][align=left]Description[/align][align=left]Creates a copy of the flowitem and moves itinto the container object, causing the OnReceive event of the container toexecute.[/align]
──── 0人觉得很赞 ────

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
2019-5-24 12:37:07
注意:因为是在脚本窗口编写代码,无法有效引用临时实体,只能点击临时实体,将其指定为so。

[code]createcopy(node("Queue3", model()),model);
createinstance(node("/fixedresources/Queue",library),model);
insertcopy(node("Queue3", model()),model);//不能复制固定实体
insertcopy(so,node("Queue77", model()));//只能复制临时实体[/code]
您需要登录后才可以回帖 立即登录
高级模式
返回
技术交流
热门问答
查看更多
1
厂区生产线布局优化案例!新做的!
厂区生产线布局优化案例!新做的!
12094
227
2
Flexsim二次开发之塔吊
Flexsim二次开发之塔吊
6139
45
3
FlexSim2016 中国象棋
FlexSim2016 中国象棋
6011
44
4
快递分拨中心案例~新手可参考
快递分拨中心案例~新手可参考
5633
62
5
关于Processs Flow 使用的两个案例(AGV Elevator案例/子母穿梭
关于Processs Flow 使用的两个案例(AGV Elevator案例/子母穿梭
5479
34
博主榜
+ 10630
+ 7753
+ 6759
4
+ 6323
5
+ 6321
6
+ 5341
7
+ 4710
8
+ 3722
9
+ 3628
10
+ 3566