Это что-то вроде заготовки для импорта и подготовки чертежей. В теле скрипта необходимо указать путь к dwg файлам, также можно удалить указанные слои.
Функция ObjLayerName выполняет роль фильтра - не рассматриваются сплайны из указанных в функции слоев.
--------------------------------------------------------
--mP = "23"
importFile ("path.dwg") #noPrompt
delete (for o in objects where superclassOf o == shape and (o.layer.name == "name layer 01" or o.layer.name == "name layer 02") collect o)
fn ObjLayerName obj = (
temp = true
if obj.layer.name == "acad-K2-fas" then temp = false
if obj.layer.name == "acad-K1-pl" then temp = false
if obj.layer.name == "acad-K2-pl" then temp = false
if obj.layer.name == "acad-K3-pl" then temp = false
if obj.layer.name == "acad-K4-pl" then temp = false
if obj.layer.name == "acad-K5-pl" then temp = false
if obj.layer.name == "acad-K6-pl" then temp = false
temp
)
arrShape = for o in objects where superclassOf o == shape and ObjLayerName o collect o
arrShapeC = arrShape.count
arByName = #()
for i = 1 to arrShapeC do if findItem arbyName arrShape[i].name == 0 do append arByName arrShape[i].name
arSplineByName = #()
for n in arByName do(
arNT = #()
for j in arrShape do if j.name == n do append arNT j
append arSplineByName arNT
)
for s in arSplineByName do(
convertToSplineShape s[1]
for i=2 to s.count do(
convertToSplineShape s[i]
addAndWeld s[1] s[i] -1
)
updateShape s[1]
)
arrShape = for o in objects where superclassOf o == shape and ObjLayerName o collect o
arrShapeC = arrShape.count
ms = arrShape[1]
convertToSplineShape ms
for i = 2 to arrShapeC do(
convertToSplineShape arrShape[i]
addAndWeld ms arrShape[i] -1
)
updateShape ms
--delete blocks
delete (for o in objects where superclassOf o != shape collect o)
--delete empty layers
--set 0-layer to be current
(layermanager.getlayer 0).current = true
for i = Layermanager.count-1 to 1 by-1 do(
(layermanager.getLayer i).nodes &theNodes
if thenodes.count== 0 do LayerManager.deleteLayerbyname (layermanager.getLayer i).name
)
select ms
ms.name = "K6_floor_"+mP
------add newObj to layer
theLayer = layermanager.getLayerFromName $K6_floor_01.layer.name
theLayer.addNode ms
--------------------------------------------------------
Функция ObjLayerName выполняет роль фильтра - не рассматриваются сплайны из указанных в функции слоев.
--------------------------------------------------------
--mP = "23"
importFile ("path.dwg") #noPrompt
delete (for o in objects where superclassOf o == shape and (o.layer.name == "name layer 01" or o.layer.name == "name layer 02") collect o)
fn ObjLayerName obj = (
temp = true
if obj.layer.name == "acad-K2-fas" then temp = false
if obj.layer.name == "acad-K1-pl" then temp = false
if obj.layer.name == "acad-K2-pl" then temp = false
if obj.layer.name == "acad-K3-pl" then temp = false
if obj.layer.name == "acad-K4-pl" then temp = false
if obj.layer.name == "acad-K5-pl" then temp = false
if obj.layer.name == "acad-K6-pl" then temp = false
temp
)
arrShape = for o in objects where superclassOf o == shape and ObjLayerName o collect o
arrShapeC = arrShape.count
arByName = #()
for i = 1 to arrShapeC do if findItem arbyName arrShape[i].name == 0 do append arByName arrShape[i].name
arSplineByName = #()
for n in arByName do(
arNT = #()
for j in arrShape do if j.name == n do append arNT j
append arSplineByName arNT
)
for s in arSplineByName do(
convertToSplineShape s[1]
for i=2 to s.count do(
convertToSplineShape s[i]
addAndWeld s[1] s[i] -1
)
updateShape s[1]
)
arrShape = for o in objects where superclassOf o == shape and ObjLayerName o collect o
arrShapeC = arrShape.count
ms = arrShape[1]
convertToSplineShape ms
for i = 2 to arrShapeC do(
convertToSplineShape arrShape[i]
addAndWeld ms arrShape[i] -1
)
updateShape ms
--delete blocks
delete (for o in objects where superclassOf o != shape collect o)
--delete empty layers
--set 0-layer to be current
(layermanager.getlayer 0).current = true
for i = Layermanager.count-1 to 1 by-1 do(
(layermanager.getLayer i).nodes &theNodes
if thenodes.count== 0 do LayerManager.deleteLayerbyname (layermanager.getLayer i).name
)
select ms
ms.name = "K6_floor_"+mP
------add newObj to layer
theLayer = layermanager.getLayerFromName $K6_floor_01.layer.name
theLayer.addNode ms
--------------------------------------------------------
Комментариев нет:
Отправить комментарий