AutoLisp Help
AutoLisp Help
(OP)
I am looking for a way to move an object to another layer, based on it's current layer. For example: Say I have a line on a layer called "1" I want to be able to select that line and automatically move it to another layer called "x-1" which may or may not exist. I would also like to be able to select more than one object at a time, and have them all go to other layers based on their current layers. "1" to "x-1", "2" to "x-2", "column" to "x-column", etc.
Whatever layer the object is on, take that name and create a new layer with an "X" prefix, or if the x-layer exists, just move it to that layer.
Does this all make sense?
I would like to do this myself, but haven't gotten this deep into lisp and need some direction to get started.
If anybody has ideas or anything, I would appreciate hearing them.
Thanks
Chris
Whatever layer the object is on, take that name and create a new layer with an "X" prefix, or if the x-layer exists, just move it to that layer.
Does this all make sense?
I would like to do this myself, but haven't gotten this deep into lisp and need some direction to get started.
If anybody has ideas or anything, I would appreciate hearing them.
Thanks
Chris





RE: AutoLisp Help
1 = text value (text string, attribute value)
2 = text value (block name, attribute info)
3 = text value (attribute info)
5 = handle (read only)
7 = text style
8 = layer
10 = point
11 = point
12 = point
40 = text size
62 = color (integer values only)
210 = point (ucs orientation)
There are many more, some the program will not modify, others it will without a hitch. It is very powerful, once you understand the DXF groups.
Send me an email so I can forward it to you if you want it.
lisper@-nospam-bcinc.hypermart.net
remove the -nospam- portion of the address
Cheers....
RE: AutoLisp Help
The next routine, to import layers from a txt file is incomplete. Maybe you can work on it.
Then, we need a routine to check if the layer exists.
Then, a routine to make selection sets by layers and change the layers.
Not simple...
Good luck
(defun C:LayerTranslate()
(princ "Statring to convert layers")
;(ExportLayerNames "LayerExport.txt")
;(GetLayerTranslation "LayerTranslate.txt")
;(ConvertLayersInDWG)
)
(defun ExportLayerNames(fileName)
(princ "Statring to convert layers")
)
(defun dxf (n ed) (cdr (assoc n ed)))
(defun C:ExportLayers()
;open LayerSource.txt to export layers of the current drawings
(setq mySource (open "LayerSource.txt" "w"))
;get all layers in the drawing
(setq onlayers (list ""))
(Print (strcat "2LayerName " "6LineType " "62Color "))
(print)
(setq layer1 (tblnext "LAYER" t))
;(print layer1)
;(dxf 2 layer1) is Layer Name
;(dxf 6 layer1) is linetype of the layer
;(dxf 62 layer1) is -1 for off layer, color for on layers. Like 3 for green
;(dxf 70 layer1) is 0 for normal layers, is 48 for XREF layers
(setq ThisLayer (list (dxf 2 layer1) (dxf 6 layer1) (dxf 62 layer1)))
(mapcar 'print Thislayer)
(princ "\"" mySource)
(princ Thislayer mySource)(princ "\"" mySource)(princ "\n" mySource)
(while (setq layer1 (tblnext "LAYER"))(progn
;(print layer1)
(setq ThisLayer (list (dxf 2 layer1) (dxf 6 layer1) (dxf 62 layer1)))
(mapcar 'print Thislayer)(print)
(princ "\"" mySource)
(princ Thislayer mySource)(princ "\"" mySource)(princ "\n" mySource)
))
(close mySource)
(findfile "LayerSource.txt")
)
(defun C:ImportLayers()
(setq mySource (open "LayerSource.txt" "r"))
(while (setq thisLayer (read-line mySource))
(if (strlen thislayer)(progn
(setq thisLayer (read thislayer))
(princ thisLayer)(princ "\n")
(princ (car (princ thisLayer)))
))
)
(close mySource)
)
RE: AutoLisp Help
Anyway, thanks for the help, and if anyone else has other ideas, I would still like to see them.