|
楼主 |
发表于 2011-7-15 21:30
|
显示全部楼层
来自: 中国江苏镇江
应网友要求,现贴出源码:
###################
import kcs_util,kcs_ui
import kcs_hullpan
import kcs_draft
import KcsPoint2D
import KcsModel
import KcsPoint3D
import KcsStat_point3D_req
import KcsStat_point2D_req
import kcs_hull
OK = kcs_util.success()
CANCEL = kcs_util.cancel()
group_given = 0
#------------------------------------------------------------------------------
# getPanelGroups - get all groups \view from a panel
#------------------------------------------------------------------------------
def getPanelGroups(panel,group):
groups = []
if group > 0:
groups.append(group)
else:
groupres = kcs_hull.pan_next_group( panel, -2, group) #获取板架的组号
res = groupres[0]
while res == OK:
group = groupres[1]
groups.append(group)
groupres = kcs_hull.pan_next_group( panel, 1, group) #获取板架的下个组号
res = groupres[0]
# kcs_ui.message_confirm(str(group))
return groups
#-----------------------------------------------------------------------------
# Main body
#-----------------------------------------------------------------------------
stat=KcsStat_point2D_req.Stat_point2D_req()
stat.SetDefMode("ModeNode")
point=KcsPoint2D.Point2D() #initialise point
res = kcs_ui.point2D_req("Indicate origo",point,stat)
if res[0] !=kcs_util.ok():
kcs_ui.message_confirm("user interrupt")
else:
p3D1 = kcs_util.tra_coord_ship(point.X,point.Y,"")
if p3D1[0] == 0:
ORI = "%0.1f,%0.1f,%0.1f" % p3D1[1:]
res1 = kcs_util.coord_to_pos(1,p3D1[1])
if res1[0] == 0:
p1 = "X=FR%s+%d" % res1[1:]
res2 = kcs_util.coord_to_pos(2,p3D1[2])
if res2[0] == 0:
p2 = "Y=LP%s+%d" % res2[1:]
p3 = "Z = %d" % p3D1[3]
kcs_ui.message_confirm("ORI:"+p1 +","+p2+"," +p3)
res = kcs_ui.point2D_req("Indicate U-axis",point,stat)
if res[0] !=kcs_util.ok():
kcs_ui.message_confirm("user interrupt")
else:
p3D2 = kcs_util.tra_coord_ship(point.X,point.Y,"")
if p3D2[0] == 0:
UAX = "%0.1f,%0.1f,%0.1f" % p3D2[1:]
res1 = kcs_util.coord_to_pos(1,p3D2[1])
if res1[0] == 0:
p1 = "X=FR%s+%d" % res1[1:]
res2 = kcs_util.coord_to_pos(2,p3D2[2])
if res2[0] == 0:
p2 = "Y=LP%s+%d" % res2[1:]
p3 = "Z = %d" % p3D2[3]
kcs_ui.message_confirm("UAX:"+p1 +","+p2+"," +p3)
res = kcs_ui.point2D_req("Indicate V-axis",point,stat)
if res[0] !=kcs_util.ok():
kcs_ui.message_confirm("user interrupt")
else:
p3D3 = kcs_util.tra_coord_ship(point.X,point.Y,"")
if p3D3[0] == 0:
VAX = "%0.1f,%0.1f,%0.1f" % p3D3[1:]
VAX = "%0.1f,%0.1f,%0.1f" % p3D3[1:]
res1 = kcs_util.coord_to_pos(1,p3D3[1])
if res1[0] == 0:
p1 = "X=FR%s+%d" % res1[1:]
res2 = kcs_util.coord_to_pos(2,p3D3[2])
if res2[0] == 0:
p2 = "Y=LP%s+%d" % res2[1:]
p3 = "Z = %d" % p3D3[3]
kcs_ui.message_confirm("VAX:"+p1 +","+p2+"," +p3)
mod = kcs_ui.req_pick_mod("Pick panel",0,0) #点击得到一个板架
res = mod[0]
#kcs_ui.message_confirm(str(OK) + str(res)+mod[1])
if res == OK and mod[1] == "plane panel":
panel = mod[2]
res = kcs_hull.pan_modify(panel,2) #激活一个板架,1=新;2=更新
# groups = getPanelGroups( panel, group_given) #获取板架的语句,因为是新加肘板,所以不要查找语句编号
status, A = kcs_ui.int_req("A")
if status == kcs_util.ok() :
kcs_ui.message_confirm(A)
status, B = kcs_ui.int_req("B")
if status == kcs_util.ok() :
kcs_ui.message_confirm(B)
status, MAT = kcs_ui.int_req("MAT")
if status == kcs_util.ok() :
kcs_ui.message_confirm(MAT)
status, H = kcs_ui.int_req("H")
if status == kcs_util.ok() :
kcs_ui.message_confirm(H)
status, NOT = kcs_ui.string_req("NOT")
if status == kcs_util.ok() :
kcs_ui.message_confirm(NOT)
status, PSI = kcs_ui.string_req("PSI")
if status == kcs_util.ok() :
kcs_ui.message_confirm(PSI)
# Bracket parameters
stBRA = "BRA, KLK, COR=0,COL=CYAN, MAT= %d, NOT= %s, MSI=PS, A= %d, B= %d,H=%d,PSI= %s, V2= 90, ORI = %s, UAX = %s, VAX = %s ;" % (MAT,NOT, A, B, H, PSI, ORI, UAX,VAX) #定义属性
try:
kcs_hullpan.stmt_exec(0, stBRA) #新加语句时,语句的编号=0
kcs_hullpan.pan_store()
try:
kcs_ui.pic_draw_mod('plane panel', panel, 0) #重新生成(新)板架.
except:
kcs_ui.message_confirm("bracket not gotten")
finally:
kcs_hullpan.pan_skip() #skip (deactivate) the scheme |
评分
-
查看全部评分
|