吸取属性

--------------------
global copy_wir_col = true        -- 吸取线框颜色
global copy_mat = true            -- 吸取材质
global copy_name = true        -- 吸取名字
global copy_modify = true        -- 吸取修改器
global copy_layer = true        -- 吸取图层
--------------------
fn FN_copyset =        --吸取属性设置函数
(
    try (destroydialog copyset_Roll)catch()
    rollout copyset_Roll "关联属性设置" width:110 height:150
    (
        checkbox chk_wirecolor "关联颜色" pos:[20,9] width:70 height:20
        checkbox chk_material "关联材质" pos:[20,30] width:70 height:20
        checkbox chk_name "统一名字" pos:[20,51] width:70 height:20
        checkbox chk_modify "关联修改器" pos:[20,72] width:80 height:20
        checkbox chk_layer "统一图层" pos:[20,93] width:70 height:20 
        button btn_ok "确定" pos:[20,120] width:70 height:25
        
        on copyset_Roll open do
        (
            chk_material.state = copy_mat
            chk_wirecolor.state = copy_wir_col
            chk_name.state = copy_name
            chk_modify.state = copy_modify
            chk_layer.state = copy_layer
        )
        on chk_material changed state do
            copy_mat = state
        on chk_wirecolor changed state do
            copy_wir_col = state
        on chk_name changed state do
            copy_name = state
        on chk_modify changed state do
            copy_modify = state
        on chk_layer changed state do
            copy_layer = state
        on btn_ok pressed do
            destroydialog copyset_roll
    )
    createdialog copyset_Roll style:#(#style_toolwindow, #style_sysmenu)
)
fn FN_copypro =        --吸取属性
(
    obj_pick=pickObject()
    if (selection.count != 0) and (obj_pick != undefined) then
    (
        if copy_wir_col then ($.wirecolor = obj_pick.wirecolor)        -- 线框颜色
        if copy_mat then ($.material = obj_pick.material)        -- 材质
        if copy_name then        -- 统一名字
        (
            for m = 1 to selection.count do (selection[m].name = uniqueName obj_pick.name)
        )
        if copy_modify then    -- 吸取所有修改器 
        (
            if obj_pick.modifiers != 0 then
            (
                for m = 1 to selection.count do 
                (
                    
                    for u = obj_pick.modifiers.count  to 1 by -1 do  try( addModifier selection[m]  obj_pick.modifiers[u])catch()
                )
            )
        )
        if copy_layer then     -- 吸取图层
        (
            vLayer =obj_pick.INodeLayerProperties.layer
            for e in selection do vLayer.addNode e
        )
    )
    else(messagebox "请先选择物体!")
)
posted @ 2019-12-27 23:14  HU_M  阅读(180)  评论(0编辑  收藏  举报