antistar Posted August 24, 2010 Posted August 24, 2010 Hi to all. I need two subroutines to make visible and invisible objects stored in the variable "SS" of the code below: (setq SS (ssget "_C" '(0 0)' (0 0))) I would like to be implemented like this: (VIS "SS") and (INVIS "SS") Can anyone help me? Thanks in advance. Quote
rkmcswain Posted August 24, 2010 Posted August 24, 2010 You could do something like this also... (change false to true to restore visibility) (setq i 0) (repeat (sslength ss) (setq obj (vlax-ename->vla-object (ssname ss i))) (vlax-put-property obj 'Visible :vlax-false) (setq i (1+ i)) ) Quote
antistar Posted August 24, 2010 Author Posted August 24, 2010 Is not working... (vl-load-com) (setq ss (ssget "_C" '(0 0) '(0 0))) (if ss (command "_.erase" ss "")) (setq f (open "c:\\LIST.txt" "r")) (setq txt (read-line f)) (while (/= nil txt) (command "-text" "J" "BL" "0,0" 1 0 txt) (setq txt (read-line f)) ) (setq in 0) (repeat (sslength ss) (setq obj (vlax-ename->vla-object (ssname ss in))) (vlax-put-property obj 'Visible :vlax-false) (setq in (1+ in)) ) Quote
Lee Mac Posted August 24, 2010 Posted August 24, 2010 I wrote these a while back, they may assist you: (defun c:AllVis ( / tmp ) ;; Lee Mac ~ 27.04.10 (if (setq tmp (ssget "_X")) ( (lambda ( i / e ) (while (setq e (ssname tmp (setq i (1+ i)))) (Update (PutDXF 60 0 (entget e)) ) ) ) -1 ) ) (princ) ) (defun c:Invis ( / tmp ) ;; Lee Mac ~ 27.04.10 (if (setq tmp (ssget "_:L")) ( (lambda ( i / e ) (while (setq e (ssname tmp (setq i (1+ i)))) (Update (PutDXF 60 1 (entget e)) ) ) ) -1 ) ) (princ) ) (defun PutDXF ( code value elist ) (entmod (if (assoc code elist) (subst (cons code value) (assoc code elist) elist) (append elist (list (cons code value))) ) ) ) (defun Update ( elist ) (entupd (cdr (assoc -1 elist))) ) Quote
antistar Posted August 24, 2010 Author Posted August 24, 2010 Lee, ALLVIS returns error message in CAD2002: Command: allvis ; error: bad argument type: lentityp nil Coommand Quote
BlackBox Posted August 24, 2010 Posted August 24, 2010 There are several problems with this, but to identify a few: Is not working... (vl-load-com) (setq ss (ssget "_C" '([color=red]0 0[/color]) '([color=red]0 0[/color]))) [color=seagreen]; <- Nothing is selected (nil)[/color] (if ss (command "_.erase" ss "")) [color=seagreen]; <- So there's nothing to erase (also nil)[/color] (setq f (open "c:\\LIST.txt" "r")) (setq txt (read-line f)) (while (/= nil txt) (command "-text" "J" "BL" "0,0" 1 0 txt) (setq txt (read-line f)) ) (setq in 0) (repeat (sslength ss) [color=#2e8b57];; You already erased ss entities above[/color] (setq obj (vlax-ename->vla-object (ssname ss in))) [color=seagreen][color=seagreen];; Which throws an error because there's nothing in ss[/color][/color] [color=seagreen][color=seagreen];; ; error:[/color] bad argument type: VLA-OBJECT nil[/color] (vlax-put-property obj 'Visible :vlax-false) (setq in (1+ in)) ) Quote
antistar Posted August 24, 2010 Author Posted August 24, 2010 RenderMan, thanks for your explanations. So I'll change my question: How do I become invisible every object text that is in point 0.0? Quote
BlackBox Posted August 24, 2010 Posted August 24, 2010 How do I become invisible every object text that is in point 0.0? You're welcome. It appears that you are deleting an old text label, and replacing it with a new, and then you want to make that new label invisible... am I correct? Quote
Lee Mac Posted August 24, 2010 Posted August 24, 2010 Lee, ALLVIS returns error message in CAD2002: Command: allvis ; error: bad argument type: lentityp nil Coommand All seems fine to me - there isn't too much that can go wrong. Quote
antistar Posted August 24, 2010 Author Posted August 24, 2010 You're welcome. It appears that you are deleting an old text label, and replacing it with a new, and then you want to make that new label invisible... am I correct? Exactly, this is it. Quote
antistar Posted August 24, 2010 Author Posted August 24, 2010 All seems fine to me - there isn't too much that can go wrong. Lee, The function ALLVISs would be very important to me so I make visible all objects in the drawing. But it does not work for me. Quote
Lee Mac Posted August 24, 2010 Posted August 24, 2010 Lee, The function ALLVISs would be very important to me so I make visible all objects in the drawing. But it does not work for me. Have you tried opening a new doc and trying it, or perhaps restart ACAD and try? I can't immediately see anything wrong with my code - unless anyone else can? Quote
BlackBox Posted August 24, 2010 Posted August 24, 2010 RenderMan, thanks for your explanations.So I'll change my question: How do I become invisible every object text that is in point 0.0? Have you tried opening a new doc and trying it, or perhaps restart ACAD and try? I can't immediately see anything wrong with my code - unless anyone else can? Lee, there's a problem in the lambda function that returns this error: ; error: bad argument type: lentityp nil Quote
antistar Posted August 24, 2010 Author Posted August 24, 2010 Have you tried opening a new doc and trying it, or perhaps restart ACAD and try? I can't immediately see anything wrong with my code - unless anyone else can? Lee, Restarted AutoCAD and worked perfectly. Thanks for your help. Quote
Lee Mac Posted August 24, 2010 Posted August 24, 2010 Lee, there's a problem in the lambda function that returns this error: ; error: bad argument type: lentityp nil I wish I could reproduce it... I can't even see the error in the code unless its a typo that I'm overlooking... Quote
BlackBox Posted August 24, 2010 Posted August 24, 2010 I wish I could reproduce it... I can't even see the error in the code unless its a typo that I'm overlooking... I'm not sure what it is...??? I just did a restart of LDC, Map, and VLIDE... and still the error persits in a new drawing. Quote
BlackBox Posted August 24, 2010 Posted August 24, 2010 c:Invis works just fine... it is only the c:Allvis that returns an error. Quote
Lee Mac Posted August 24, 2010 Posted August 24, 2010 c:Invis works just fine... it is only the c:Allvis that returns an error. As I say, I cannot see any mistake in my coding. Quote
BlackBox Posted August 24, 2010 Posted August 24, 2010 As I say, I cannot see any mistake in my coding. Nor can I, Lee... it must be with my machine. Quote
antistar Posted August 24, 2010 Author Posted August 24, 2010 Lee, You know how to apply the INVIS function to make invisible all the objects inserted in point 0.0? Quote
Recommended Posts
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.