【Skill】如何从底层快速Copy Layer到顶层
1.利用dbShapeQuery函数
hier_list = dbShapeQuery(cv list("M1" "drawing") enterBox(?points mouseAddPt()))
2.利用transform dbCopyFig
foreach(hier hier_list
;;hier_trans_list = hier~>transform
;;hier_trans = nth(length(hier_trans_list)-2 hier_trans_list)
;;if(length(hier_trans_list)>2
;; then
;; for(n o length(hier_trans_list) - 3
;; hier_trans = dbConcatTransform(hier_trans nth(length(hier_trans_list)-3-n hier_trans_list))
;; );end for
;;);end if
hier_trans = dbGetInstTransform(hier)
dbCopyFig(car(last(hier)) cv hier_trans)
);end foreach
3.最后可以再包一个界面
procedure(CopyShape_Fields()
lay_field = hiCreateStringField(
?name `lay_field
?prompt "Layer Name"
?defValue ""
?callback nil
?editable t
)
pur_field = hiCreateStringField()
button_field = hiCreateBooleanButton(
?name `button_field
?buttonText "Use this layer"
?defValue nil
?callback "CopyShape_callback(hiGetCurrentForm())"
)
list(lay_field pur_field button_field)
);end pro
procedure(CopyShape_callback(theForm)
if(theForm~>botton_field~>value == t
then
theForm~>lay_field~>value = car(leGetEntryLayer())
theForm~>pur_field~>value = cadr(leGetEntryLayer())
else
theForm~>lay_field~>value = ""
theForm~>pur_field~>value = ""
);end if
);end pro
procedure(CopyShape_CreateForm()
hiCreateAppForm(
?name `CopyShape_form
?fields CopyShape_fields()
?formTitle "Copy Shape"
?callback "CopyShapeFromHier(lay_field~>valye putr_field~>value)"
?buttonLayout `OKCancle
)
hiDisplayForm(`CopyShape_form)
);end pro