CAD Forum - Database of tips, tricks and utilities for AutoCAD, Inventor and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 5282
RSS channel - CAD tips RSS tips
RSS discussions

Discussion Discussion forum


HelpCAD discussion

CAD Forum - Homepage CAD discussion forum - ask any CAD-related questions here, share your CAD knowledge on AutoCAD, Inventor, Revit and other Autodesk software with your peers from all over the world. To start a new topic, choose an appropriate forum.

Please abide by the rules of this forum.

How to post questions: register or login, go to the specific forum and click the NEW TOPIC button.
  FAQ FAQ  Forum Search   Events   Register Register  Login Login


 Post Reply Post Reply
SAGGIAAAA View Drop Down

Joined: 24.May.2023
Location: Italy
Using: AutoCAD2024
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote SAGGIAAAA Quote  Post ReplyReply Direct Link To This Post Topic: File LISP
    Posted: 24.May.2023 at 10:25
Hello, I wrote a .lsp code to make my work easier, but unfortunately I'm unable to get it to work properly. Does anyone know how to resolve this? I'm attaching the code.

(defun c:ComandName(/ sel ss blk obj)
  (defun ename->vla-object (ename)
    (if (not (vlax-dump-object ename))
      (vlax-ename->vla-object ename)
      (vl-catch-all-error-p nil
        (vl-catch-all-apply 'vla-get-object
          (list (vlax-ename->vla-object ename))

  (setq sel (ssget "_X" '((0 . "INSERT"))))
  (if sel
      (setq blk (ename->vla-object (ssname sel 0)))
      (vla-put-layer blk "0")
      (vla-put-color blk (vla-get-property blk 'Color))
      (vla-put-linetype blk (vla-get-property blk 'Linetype))
      (setq sel (ssget "_X" '((0 . "TEXT")) (list (cons 2 (strcat "\\A" "\\*U")))))
      (if sel
        (command "._CHPROP" sel "" "c" "" "Yellow" "")
      (setq sel (ssget "_X" '((0 . "TEXT")) (list (cons 2 "A"))))
      (if sel
        (command "._CHPROP" sel "" "la" "" "Defpoint" "")
      (setq sel (ssget "_X" '((0 . "POINT"))))
      (if sel
        (command "._CHPROP" sel "" "la" "" "Defpoint" "")
      (command "SCALE" "All" "" "0,0" "1:1" "mm" "" "No" "")
      (command "._EXPLODE" sel)

The code must: open the selected block(s), move all objects to layer 0 with the color "DaBlocco," thickness "DaBlocco," and line type "DaBlocco." Then, select only the text/annotations within the block and set their color to yellow. If the text is an "A," it should be placed on the "Defpoint" layer. Additionally, select the points contained within the block and move them to the "Defpoint" layer. Finally, set the block's scale to "millimeters" and allow for exploding the block. As a final step, automatically close the block. All of this should be done without any action required from you except for activating the command after selecting the blocks to be edited. thanks to all who will help me.
Back to Top
Kent Cooper View Drop Down
Senior Member
Senior Member

Joined: 12.Mar.2013
Location: United States
Using: AutoCAD2020, 2023
Status: Online
Points: 592
Post Options Post Options   Thanks (0) Thanks(0)   Quote Kent Cooper Quote  Post ReplyReply Direct Link To This Post Posted: 24.May.2023 at 14:29
Originally posted by SAGGIAAAA SAGGIAAAA wrote:

.... it should be placed on the "Defpoint" layer. ....

The Layer name has an s on the end, which may explain your problem [I did not analyze other things -- there may be more issues].  BUT DON'T USE THAT LAYER FOR THIS PURPOSE!  It has a special purpose in AutoCAD, and is not for Users to involve themselves with.  The use of it for things to not Plot dates back to the days [very long ago now] when that was the only Layer that didn't Plot.  But for many years now you can designate any Layer to not Plot.  So make a non-Plotting Layer for the purpose, and give it a name that has some meaning in relation to what it's for.
Back to Top

Related CAD tips:

 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

This page was generated in 0,063 seconds.