|
本帖最后由 lzt20007 于 2011-7-28 13:29 编辑
小弟初学tribon,遇到很多问题,特来求救。希望各位大哥、大姐帮帮忙啊!
是这样的:我想写个程序,用来从tribon中抽取船体(HULL)的三维模型(3D DXF)。程序运行中出现了错误,但是查看日志却不知道为什么错了(kcsmodel.model这句!)。
程序在tribon自带的vitesse中调试,想把dxf文件导出到"c\dxf\"中。源代码如下:
import kcs_ui
import KcsVector3D
import KcsPoint2D
import kcs_draft
import kcs_gui
import kcs_util
import kcs_db
import kcs_dex
from KcsObjectCriteria import ObjectCriteria
import os
def GetPanelsInBlock(blockname):
panelList = []
st = "HULL.BLOCK('" + blockname + "').PANEL(*).NAME"
kcs_ui.message_noconfirm("st: " + st)
if kcs_dex.extract(st) == 0:
dataType = kcs_dex.next_result()
while dataType >= 0:
if 3 == dataType:
panelName = kcs_dex.get_string()
panelList.append(panelName)
dataType = kcs_dex.next_result()
return panelList
def Export3D(dbtype,blockname,leavel):
panelList = GetPanelsInBlock(blockname)
if 1 == kcs_draft.dwg_current():
kcs_draft.dwg_close()
try:
kcs_draft.dwg_new("test","",dbtype)
except:
kcs_ui.message_noconfirm("dwg_new" + kcs_draft.error)
x = kcs_draft.view_new("View_new")#
for panel in panelList:
modeltype = "plane panel"
try:
model = KcsModel.Model( modeltype, panel) <------------------------------------------错误在这里!!!!
kcs_ui.message_noconfirm("KcsModel.Model next: " + panel)
except:
kcs_ui.message_noconfirm("KcsModel.Model() Error!" )
try:
kcs_draft.model_draw(model)
except:
kcs_ui.message_noconfirm("model_draw " + kcs_draft.error)
modeltype = "curved panel"
model = KcsModel.Model( modeltype, (panel))
kcs_draft.model_draw(model)
y = []
y.append(x)
try:
kcs_draft.dwg_dxf_3d_export(blockname,y,leavel)
except:
kcs_ui.message_noconfirm("dwg_dxf_3d_export" + kcs_draft.error)
#-------------------------main()----------------------
try:
level = 3
list = []
kcs_db.object_list_get(ObjectCriteria(),"SB_OGDB",list)
list = map(lambda x : x.GetName(), list)
n = len(list)
kcs_ui.message_noconfirm("-------checking drawing names--------")
for i in range(n):
kcs_ui.message_noconfirm(" %d : "%i + list)
req = kcs_ui.answer_req("prompt","There are %d piece of drawing.Do you want to export."%n)
if req == kcs_util.yes():
if not os.path.exists('c:\dxf'):
os.makedirs(r'c:\dxf')
for i in range(1):
name = list
dxfname = name.replace(":","_")
Export3D("SB_OGDB",dxfname,level)
kcs_ui.message_confirm("Export is succeed")
except:
kcs_ui.message_confirm("Error in Main()!") #"Error in Main()!"
就这么多分了,各位船友们帮帮啊!!! |
|