|
如何解决参数化CableWay辅助建模CableWay间自动连接问题
问题:
为用户开发一个参数化CableWay建模程序,用户要求将根据用户填入的参数,在CableModelling环境中,自动创建CableWay,并使CableWay能自动连接。
根据用户要求立即着手编写Python脚本程序,第一的功能很容易实现,但是第二个功能不能达到用户之要求,CableWay在CableModelling环境中创建完成后,其有物理连接的两两CableWay则不能自动连接。在CableModelling环境中,用户以交互方式设绘CableWay时,CableWay能自动连接,而以程序创建的CableWay反而不能连接,究其原因,如下:
交互方式:用户使用对象捕捉来拾取连接点,系统可以得到被连接的CableWay名和连接点信息,所以其能自动连接。
程序方式:纯粹设绘CableWay,没有给出被连接的CableWay及连接点信息。
摸索:
根据此情况,再次认真阅读了TRIBON开发包的Cable开发文档,发现对于CableWay的创建尚有如下函数可以使用:
kcs_cable.default_value_set (statement)
kcs_cable.cway_cwenv_clear()
kcs_cable.cway_cwenv_incl(name)
kcs_cable.cway_cwenv_connect()
于是本人用尽以上这些函数,做各种组合测试,见测试PYTHON脚本CwayTest4.py,由于没有范例,故我反反复复,一遍又一遍地做测试,都没有达到预期效果,函数kcs_cable.cway_cwenv_connect() 好象是在交互环境中使用方可,它无参数输入,但需要两个条件,一条激活的CableWay(激活CableWay没有问题),一条被选择的CableWay(这个有问题,在runtime环境中,没有选择CableWay的函数,在交互状况下就可以),所以此函数好象没有实用价值。其实这个函数应该带参数的,参数应当这样设置kcs_cable.cway_cwenv_connect(CW1,CW2,CNPoint)
要求输入三个参数CW1:被连接电缆通道,CW2:连接电缆通道,CNPoint:连接点,这样就可以以编程的方式为CableWay建立连接点了。不知道TRIBON的开发者是怎么想的,或许此问题的解决要等到AVEVA公司打补钉,或许我没有摸透它。
先前在论坛上看到大连重工的杨光先生介绍说:“他们厂已经实现了多种模型的参数化建模,也包括CableWay的参数化建模吧”,想必这个问题,他早已解决了,所以现在特请杨光兄或其他高手指点迷津,以期解决这个问题,共同为中国的造船事业做出贡献。
多谢!
测试PYTHON脚本CwayTest4.py
#
# NAME:
#
# kcs_ex_CwayTest4.py
#
# PURPOSE:
#
# This program serve to create two new cableway
#
import re
import string
import kcs_util
import kcs_ui
import kcs_cable
import KcsColour
import KcsStringlist
import kcs_dex
import KcsPoint3D
import KcsStat_point3D_req
import KcsModel
import kcs_draft
#---------------------------------------------------------------------------------------
def RouteParts1():
print 'Route'
point = KcsPoint3D.Point3D()
point.X=0.0
point.Y=0.0
point.Z=0.0
try:
point.X=19200.0
point.Y=4600.0
point.Z=32400.0
kcs_cable.cway_route_start_point(point)
point.X=18400.0
point.Y=4600.0
point.Z=32400.0
kcs_cable.cway_route_point(point)
point.X=18400.0
point.Y=3200.0
point.Z=32400.0
kcs_cable.cway_route_point(point)
point.X=18400.0
point.Y=2500.0
point.Z=32400.0
kcs_cable.cway_route_point(point)
point.X=18400.0
point.Y=2300.0
point.Z=32400.0
kcs_cable.cway_route_point(point)
point.X=18400.0
point.Y=1214.0
point.Z=32400.0
kcs_cable.cway_route_end_point(point)
except:
kcs_ui.message_noconfirm(str(sys.exc_info()[1]))
print kcs_ui.error
#---------------------------------------------------------------------------------------
def RouteParts2():
print 'Route'
point = KcsPoint3D.Point3D()
point.X=0.0
point.Y=0.0
point.Z=0.0
try:
point.X=18159.0
point.Y=4600.0
point.Z=32400.0
kcs_cable.cway_route_start_point(point)
point.X=18400.0
point.Y=4600.0
point.Z=32400.0
kcs_cable.cway_route_end_point(point)
except:
kcs_ui.message_noconfirm("Wrong point !")
print kcs_ui.error
#---------------------------------------------------------------------------------------
def Createimaginarypenetration1(cablewayname):
print 'Route'
point = KcsPoint3D.Point3D()
point.X=0.0
point.Y=0.0
point.Z=0.0
try:
point.X=19200.0
point.Y=4600.0
point.Z=32400.0
name='L6/126'
kcs_cable.cpen_imag_new(name, cablewayname, point)
point.X=18400.0
point.Y=4600.0
point.Z=32400.0
name='L6/120'
kcs_cable.cpen_imag_new(name, cablewayname, point)
point.X=18400.0
point.Y=3200.0
point.Z=32400.0
name='L6/283'
kcs_cable.cpen_imag_new(name, cablewayname, point)
point.X=18400.0
point.Y=2500.0
point.Z=32400.0
name='L6/001'
kcs_cable.cpen_imag_new(name, cablewayname, point)
point.X=18400.0
point.Y=2300.0
point.Z=32400.0
name='L6/110'
kcs_cable.cpen_imag_new(name, cablewayname, point)
point.X=18400.0
point.Y=1214.0
point.Z=32400.0
name='L6/108'
kcs_cable.cpen_imag_new(name, cablewayname, point)
except:
kcs_ui.message_noconfirm(str(sys.exc_info()[1]))
print kcs_ui.error
#---------------------------------------------------------------------------------------
def Createimaginarypenetration2(cablewayname):
print 'Route'
point = KcsPoint3D.Point3D()
point.X=0.0
point.Y=0.0
point.Z=0.0
try:
point.X=18159.0
point.Y=4600.0
point.Z=32400.0
name='L6/119'
kcs_cable.cpen_imag_new(name, cablewayname, point)
except:
kcs_ui.message_noconfirm(str(sys.exc_info()[1]))
print kcs_ui.error
#---------------------------------------------------------------------------------------
def run():
try:
# receive name, module and colour of cableway
strDefaultValue='CW_AUTO_CONN = 1'
kcs_cable.default_value_set(strDefaultValue)
kcs_cable.cway_cwenv_clear()
try:
Name = 'CWL6/116'
CWName=Name
CWName=CWName.upper()
if kcs_cable.cway_exist(CWName)==1:
kcs_cable.cway_delete(CWName)
CableWay=kcs_cable.cway_new(CWName, 'L6', 'Red')
kcs_cable.cway_activate(CWName)
RouteParts1()
kcs_cable.cway_save()
Createimaginarypenetration1(CWName)
#kcs_cable.cway_cwenv_incl(CWName)
model = KcsModel.Model('cable way', 'ZK-'+ CWName)
kcs_draft.model_draw(model)
Name = 'CWL6/118'
CWName=Name
CWName=CWName.upper()
if kcs_cable.cway_exist(CWName)==1:
kcs_cable.cway_delete(CWName)
CableWay=kcs_cable.cway_new(CWName, 'L6', 'red')
kcs_cable.cway_activate(CWName)
RouteParts2()
kcs_cable.cway_save()
Createimaginarypenetration2(CWName)
#kcs_cable.cway_cwenv_incl(CWName)
model = KcsModel.Model('cable way', 'ZK-'+ CWName)
kcs_draft.model_draw(model)
Name = 'CWL6/116'
#kcs_cable.cway_activate(Name)
#kcs_cable.cway_cwenv_connect()
#kcs_cable.cway_save()
except:
kcs_ui.message_noconfirm(str(sys.exc_info()[1]))
print kcs_ui.error
except:
kcs_ui.message_noconfirm(str(sys.exc_info()[1]))
print kcs_ui.error
#-------------------------------------------------------------------------------------------------------------
if __name__ == "__main__":
run()
附图
[ 本帖最后由 SkyLineGuest 于 2008-3-10 14:55 编辑 ] |
|