+ Reply to Thread
Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 11 to 20 of 21
  1. #11
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Registered forum members do not see this ad.

    Hi Grrr,
    I think you need to exclude the VIEWPORT object from the selection set since you have used the entmod function besides that, you don't need to search if the target layer is found or existed since the cons function could create that target layer name with default values.

  2. #12
    Super Moderator SLW210's Avatar
    Computer Details
    SLW210's Computer Details
    Operating System:
    Windows 7 PRO 64-bit
    Computer:
    IBM Lenovo
    Motherboard:
    ACPI x64
    CPU:
    Pentium(R) i5 4570 @ 3.2GHz
    RAM:
    8 GB RAM
    Graphics:
    Nvidia Quadro 600 1GB
    Primary Storage:
    300 GB
    Secondary Storage:
    650GB
    Monitor:
    2x ThinkVision 24"
    Discipline
    Multi-disciplinary
    SLW210's Discipline Details
    Occupation
    Design Draftsman
    Discipline
    Multi-disciplinary
    Details
    Mostly do drafting related to manufacturing. From doing site layouts with proposed updates, additions and renovations to be budgeted and submitted for bid, to updating and changing existing drawings to reflect maintenance and repair/revision work done on site.
    Using
    AutoCAD 2018
    Join Date
    May 2007
    Location
    South Florida, USA
    Posts
    12,127

    Default

    Please read the Code Posting Guidelines and have your Code to be included in Code Tags.[CODE]Your Code Here[/CODE] =
    Code:
    Your Code Here
    “A narrow mind and a fat head invariably come on the same person” Zig Zigler



  3. #13
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,474

    Default

    Quote Originally Posted by Tharwat View Post
    Hi Grrr,
    I think you need to exclude the VIEWPORT object from the selection set since you have used the entmod function besides that, you don't need to search if the target layer is found or existed since the cons function could create that target layer name with default values.
    Hi Tharwat,
    Thanks for the advices.. I have one question regarding the VIEWPORT:
    Wheres a case for the user to select a VIEWPORT object? When working in paperspace (my guess) ?
    I always work in modelspace, so I never regarded the possibility for this issue.

    BTW for the second remark, I actually don't look if the targed layer already exists - just making sure if OP provides list of dotted pairs:
    Code:
    '( ; The routine will skip entmod'ing "Layer1"
      ("obj2" . "obj1")
      ("dim" . "0")
      ("Layer1")
    )
    But I agree its a bit inefficient to entmod with the same layer.

  4. #14
    Junior Member
    Discipline
    Structural
    Using
    AutoCAD 2017
    Join Date
    Jun 2018
    Posts
    17

    Default

    will take care of this next time thank you for your reminder.

  5. #15
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Quote Originally Posted by Grrr View Post
    Hi Tharwat,
    Thanks for the advices.. I have one question regarding the VIEWPORT:
    Wheres a case for the user to select a VIEWPORT object? When working in paperspace (my guess) ?
    I always work in modelspace, so I never regarded the possibility for this issue.
    We can't guess that all users work from / in Model space.

    Quote Originally Posted by Grrr View Post

    BTW for the second remark, I actually don't look if the targed layer already exists - just making sure if OP provides list of dotted pairs:
    Agree with that but that would ignore moving objects to targeted layer if its not existed and that is the point.

    Hope that my comment did not make any confusion.

  6. #16
    Junior Member
    Discipline
    Structural
    Using
    AutoCAD 2017
    Join Date
    Jun 2018
    Posts
    17

    Default

    Quote Originally Posted by Tharwat View Post
    Hi Grrr,
    I think you need to exclude the VIEWPORT object from the selection set since you have used the entmod function besides that, you don't need to search if the target layer is found or existed since the cons function could create that target layer name with default values.


    tharwat if you could help on sathish's code why it is not working on my system ? any thoughts ?


    test

  7. #17
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2017
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,246

    Default

    Solitechcadsolutions, you need to describe your goal of the program very clearly to all members whom wanting to help you and write the correct codes for that purpose.

    For instance;
    What are the objects that you are trying to move them to that new layer name?
    Would you like to select certain objects or let the program select them all?
    Do you have the objects on unlocked layers?

    And so on.

  8. #18
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,593

    Default

    I agree with the use of an association list, but the code could be greatly simplified, for example -
    Code:
    (defun c:laymap ( / enx idx lay map sel )
        (setq map
            (mapcar '(lambda ( x ) (cons (strcase (car x)) (cdr x)))
               '(
                    ("obj2" . "obj1")
                    ("dim"  . "0")
                )
            )
        )
        (if (setq sel (ssget "_:L" (append '((-4 . "<OR")) (mapcar '(lambda ( x ) (cons 8 (car x))) map) '((-4 . "OR>")))))
            (repeat (setq idx (sslength sel))
                (if (setq idx (1- idx)
                          enx (entget (ssname sel idx))
                          lay (cdr (assoc (strcase (cdr (assoc 8 enx))) map))
                    )
                    (entmod (subst (cons 8 lay) (assoc 8 enx) enx))
                )
            )
        )
        (princ)
    )
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  9. #19
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,474

    Default

    Nice one Lee,
    I didn't realise you could filter the layers like that, with ignoring the case of their names!

  10. #20
    Junior Member
    Discipline
    Structural
    Using
    AutoCAD 2017
    Join Date
    Jun 2018
    Posts
    17

    Default

    Registered forum members do not see this ad.

    thank you lee and grr that codes are working nicely for me ....


    Great

Similar Threads

  1. Convert to autolisp code
    By gS7 in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 5th Feb 2013, 08:51 am
  2. Select one object/entity, gripped all same entity within the layer
    By Ahmeds in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 21st Nov 2012, 01:40 pm
  3. How to convert to G-code?
    By nainuad in forum AutoCAD 3D Modelling & Rendering
    Replies: 5
    Last Post: 6th Sep 2008, 03:53 am
  4. Replies: 1
    Last Post: 26th Jun 2008, 06:32 am
  5. How to convert the VBA code to VB?
    By fenny in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 26th Jan 2005, 08:41 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts