Issue with a startup lisp opening help.

Issue with a startup lisp opening help.

cchiles
Enthusiast Enthusiast
988 Views
7 Replies
Message 1 of 8

Issue with a startup lisp opening help.

cchiles
Enthusiast
Enthusiast

I have this lisp running at startup across my network to import our current Mleader styles:

 

(setq lyr (getvar "clayer"))
(setq lyr1 (tblsearch "layer" "defpoints"))
   (if (= lyr1  nil)
(command "-layer" "make" "defpoints" "color" "9" "" "" ""))
(command "-layer" "set" "defpoints" "")

(command "-purge" "m" "" "n" )
(setvar "CMLEADERSTYLE" "standard")

(command ".-insert" "S:\\settings\\lisp\\2016\\mleaders-jst.dwg" "0,0,0" "" "" "")

(setvar "CMLEADERSTYLE" "JST Q1 Ldr")
(setvar "clayer" lyr)

(setq SS1 (ssget "X" (list '(0 . "INSERT") (cons 2 "jst-mleaders"))))
(command "erase" ss1 "")
(command "-purge" "blocks" "jst-mleaders" "N")
(princ) 

The problem is that something in here is opening the help dialog... I believe I've narrowed it down to this section:

 

(setq SS1 (ssget "X" (list '(0 . "INSERT") (cons 2 "jst-mleaders"))))
(command "erase" ss1 "")

because if I comment that part out, I don't have the issues. 

But I need that part to delete the block that is inserted.

 

Any help would be appreciated.

Maybe another way to select and delete that block? IDK.

thanks,

Chris

Thanks in advance!
-Chris
0 Likes
Accepted solutions (1)
989 Views
7 Replies
Replies (7)
Message 2 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

@cchiles wrote:

.... 

....
(command ".-insert" "S:\\settings\\lisp\\2016\\mleaders-jst.dwg" "0,0,0" "" "" "")
....
(setq SS1 (ssget "X" (list '(0 . "INSERT") (cons 2 "jst-mleaders"))))
....

... I need that part to delete the block that is inserted.

....


If by "the block that is inserted" you mean the one the routine just inserted, it would presumably be because you have reversed the elements in the Block name between the insertion and the erasure attempt.  If it doesn't find any with the "jst-mleaders" name, it will have a problem in the Erase command, since there will be no SS1 variable, which might be involved in its calling up Help.

Kent Cooper, AIA
Message 3 of 8

hmsilva
Mentor
Mentor

In addition to Kent1Cooper's suggestion, I would probably use just something like this...

 

(command "_.-purge" "_M" "" "_N")
(setvar 'CMLEADERSTYLE "standard")
(command "_.-insert" "S:\\settings\\lisp\\2016\\mleaders-jst.dwg" nil)
(setvar 'CMLEADERSTYLE "JST Q1 Ldr")
(command "_.-purge" "_B" "jst-mleaders" "_N")
(princ)

 

Hope this helps,
Henrique

EESignature

Message 4 of 8

cchiles
Enthusiast
Enthusiast
Wow. Man. It's always something so simple 90% of the time...
I did rename the file that was being inserted the other day for another reason.
Thanks for the proofread!
Thanks in advance!
-Chris
0 Likes
Message 5 of 8

cchiles
Enthusiast
Enthusiast
@hmsilva
Thanks for this streamlined version - I'm giving it a go!
Thanks in advance!
-Chris
0 Likes
Message 6 of 8

hmsilva
Mentor
Mentor

@cchiles wrote:
@hmsilva
Thanks for this streamlined version - I'm giving it a go!

You're welcome, cchiles!

Henrique

EESignature

0 Likes
Message 7 of 8

scot-65
Advisor
Advisor
Simplify the code:
(IF (NOT (tblsearch "layer" "defpoints"))...


(IF (FINDFILE "S:\\settings\\lisp\\2016\\mleaders-jst.dwg")...

and

(IF (setq SS1 (ssget "X" (list...

Otherwise what happens if any one of these are nil?

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 8 of 8

Kent1Cooper
Consultant
Consultant

@scot-65 wrote:
Simplify the code:
(IF (NOT (tblsearch "layer" "defpoints"))...
....

About that one, I was going to say there's no need to check for it, because that Layer can't be Purged, but oddly enough, it can be Renamed.  But still, there's really no need to check.  All of this:

 

(setq lyr1 (tblsearch "layer" "defpoints"))
   (if (= lyr1  nil)
(command "-layer" "make" "defpoints" "color" "9" "" "" ""))
(command "-layer" "set" "defpoints" "")

 

can be replaced by just the one Make-option line [without the extraneous Enter at the end, and without the last right parenthesis that's closing the (if) function].  Making a Layer will not have a problem if the Layer already exists -- it will notify you of that but continue -- so checking whether it exists isn't necessary.  The Make option will set it current, so that last Set line won't be needed, and will turn it on if it's off.  The only thing that can cause trouble is if it exists but is frozen, in which case it can't become current [and your longer code will also have a problem].  So the absolutely foolproof shorter replacement for the above four lines is:

 

(command "_.layer" "_thaw" "defpoints" "_make" "defpoints" "_color" "9" "" "")

 

The Thaw option won't be bothered if the Layer doesn't exist yet -- again, it will let you know but continue.

 

[Also, the hyphen before the command name doesn't do anything for you.  It's to suppress dialog boxes in commands that use them, when entering commands at the Command line, but when commands are called within an AutoLisp (command) function, dialog boxes are suppressed by default, and if you want one, you have to force it to use it -- read about (initidia).]

Kent Cooper, AIA
0 Likes