- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello guys! So I want to create a command where when I input a number, it creates several layers with the input followed by other values, with their own lineweight and colors.
Example: - If I input "123", AutoCAD should create 3 layers "[123]_1", [123]_2", [123]_3" with their own layer colors and other characteristics. However, it doesn't seem to work. It works without the brackets, but when I try it with brackets, it doesn't change any characteristics even if it does create the layers.
I'm a complete beginner in this language so I used ChatGPT, sorry haha! I do know some other languages better (JavaScript, Python) but overall I'm still at the beginning.
Here's what my code kind of looks like (simplified version):
(defun CreateLayer (layerName color lineweight)
(if (not (tblsearch "LAYER" layerName))
(progn
(command "_.-layer" "M" layerName "C" color "" "LT" "CONTINUOUS" "" "LW" (rtos lineweight) "" "")
)
)
)
(defun C:CL (/ input)
(setq input (getstring "\nWrite a number: "))
(CreateLayer (strcat "[" input "]" "_1") 1 0.5)
(CreateLayer (strcat "[" input "]" "_2") 3 0.4)
(CreateLayer (strcat "[" input "]" "_3") 7 0.25)
(princ "\nSucces!")
(princ)
)
Thank you in advance!
Solved! Go to Solution.