×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

AutoLisp Help

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
 

RE: AutoLisp Help

I have a program that changes objects (except solids) on the lowest level possible using the DXF codes for the entities. You select the object, then specify the DXF group code, then a new value for that code. It will not add a non-existent group code to an object, but it will put an object on a layer that does not exist, effectively creating the layer for you. It is not exactly what you asked for but it is close. If you are not familiar with DXF group codes, you can look them up in the help file. Just a few for your info..

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

I wanted to improvise a lisp routine in an hour or so but turned out more involved than I thought. Still, hoping it may provide the starting hints, here is what I did: a routine to export the layer names to a txt file.
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

(OP)
Thanks for respoonding and for taking time to think about this.  I kind of thought I might have to use dxf codes, however I have never done anything with them before.  Maybe I should start with something a little more basic and keep adding to it:)
Anyway, thanks for the help, and if anyone else has other ideas, I would still like to see them.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources