Very neat program. Please take a look at the one I created. It changes any line selected to color red. I found one slight problem. If the user picks something other than a line, the program goes to the properties window and changes the default color from bylayer to color red.
That is odd. The program removes the entity name from the selection set if the entity is not a line entity . The selection set was purposely built from one entity using entsel. So the selection set should be empty and not change anything. Do you see something I don't?
The selection set eset is still a selection set even if all the members have been removed. So the line "(if eset" would always be true.
Code:
(if (> (sslength eset) 0);<-- I changed this line
(progn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; CHANGE COLOR FOR ALL ENTITIES ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;--- Set the color
(setq clr 1)
;;;--- Change the color
(command "change" eset "" "Properties" "Color" clr "")
)
)
Actually that section of the code needs to be within the progn just above, or you get an error if nothing was selected.
Code:
;;;--- Make sure entity selected matches the entity types selected
(if eset
(progn
(setq enlist(entget en))
(setq enType(cdr(assoc 0 enlist)))
(if
(not
(member
enType
(list
"LINE"
)
)
)
(ssdel en eset)
)
(if (> (sslength eset) 0);<-- I changed this line
(progn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; CHANGE COLOR FOR ALL ENTITIES ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;--- Set the color
(setq clr 1)
;;;--- Change the color
(command "change" eset "" "Properties" "Color" clr "")
)
)
)
)
Hi JPS,
Here is my program. I wanted to select the DATE attribute in my border and change the value to todays date. I included my function to return todays date. I wanted to only select a single object, but the only way I could un-grey the box for the Tag Name was to select Multiple Objects. The Tag Name is just DATE. My code is not working and I'm not sure why, or even if I selected the correct choices. I think it would be nice if you provided a Back button so we can review or change things in previous dialogs. I'm also curious what the button on the Change to: line with the > symbol does. It asked me for a value on the command line.
The ">" button for the change value command is only there for you to use if the dialog box is in the way of a value shown on the graphics screen and you can't move the dialog box out of the way to see it. It simply closes the dialog box and ask you for the value on the command line while showing the graphics screen. During this time you should be able to use transparent zoom and pan commands if needed. I started to omit this but thought "why not?".
This program does not include the ability to change the value of a single block's attribute value. I did not see the need for it when autocad already has functions to accomplish this BUT I did not think about someone wanting to add their own functionality. Live and learn. Hey, this is why Beta testing is a good idea!
The only way to accomplish this using the current Creator program would be to do it for multiple blocks and then edit the program manually to select only one block.
Hi JPS,
Thanks for letting us test your program. Mine changes circles selected to the Object layer. I found one syntax error and fixed it myself. In the line (setq lay Object) I put quotes around the layer name “Object” and it works fine.
Thanks,
Ryan
P.S. By the way, will you be letting us know when the revised version is out so we can test it? Or are you just going to update the one from the link in this thread?
Code:
;;;--- RYANB003.lsp - Change Layer
;;;
;;;
;;;--- This program was created by CREATOR.lsp [ Get it free at JefferyPSanders.com ]
;;;
;;;
;;;
;;;
(defun C:RYANB003(/ cntr eset en enlist pt lay)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; ;;;
;;; Main Application ;;;
;;; ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;--- Turn the command echo off
(setvar "cmdecho" 0)
;;;--- Get a selection set
(setq eset(ssget (list(cons 0 "CIRCLE"))))
(if eset
(progn
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; CHANGE LAYER FOR ALL ENTITIES ;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;--- Set the layer
(setq lay "Object") ;it was (setq lay Object)
;;;--- Change the layer
(command "change" eset "" "Properties" "LAyer" lay "")
)
)
;;;--- Reset the command echo
(setvar "cmdecho" 1)
;;;--- Suppress the last echo for a clean exit
(princ)
)
(princ "\n Type RYANB003 to run the program.")
(princ)