Jump to content
plackowski

Undoing LISP with Visual Basic doesn't REGEN changes

Recommended Posts

plackowski

I think I'm encountering the same problem that was not resolved here.

 

I'm trying to set all the layers of an xref to layer 251. I found two codes online, posted below.

 

CVX:

(defun c:cvx (/ ent_data);;changes all layers in selected xref to color 251
(setq ent_data (entget (car (entsel))))
(command "-layer" "Color" 251 (strcat (cdr (assoc 2 ent_data)) "*")"")
)

 

X251:

(defun C:X251 (/ EN L X ad layers)
(command "UNDO" "BEGIN") 
(setq   EN (nentsel "\nSelect Xref: ")    L (cdr (assoc 8 (entget (car EN))))   X (substr L 1 (vl-string-position (ascii "|") L)) )
(setq AD (vla-get-ActiveDocument (vlax-get-Acad-Object)) layers (vla-get-Layers ad))
(if  (/= (vl-string-search "|" L) nil)
	(progn
		(vlax-for layer layers
			(if (/= (vl-string-search (strcat  X "|") (vla-get-name layer)) nil)(vla-put-Color layer 251))
		)
		(command ".REGEN")
	)
	(princ "Not an Xref!")
)
(prin1)
       (command "UNDO" "END")
)

 

I used the CVX routine for a while, until I discovered that it doesn't work if I select xrefs that are attached to overlaid xrefs. So I tried switching to the X251 routine, but if I use UNDO, the changes aren't reflected until I REGEN the drawing. I tried using an undo group as suggested in the linked post, but that didn't change the result. Any advice?

Share this post


Link to post
Share on other sites
Roy_043

Try:

(defun c:cvx ( / lst) ; Changes all layers in selected xref to color 251.
 (if
   (and
     (setq lst (nentsel))
     (= 4 (length lst))
   )
   (command "_.-layer" "_color" 251 (strcat (cdr (assoc 2 (entget (car (cadddr lst))))) "|*") "")
 )
 (princ)
)

Share this post


Link to post
Share on other sites
plackowski

That's perfect, thank you!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...