Author Topic: Help window keeps activating....grrrrrrrrr  (Read 3248 times)

0 Members and 1 Guest are viewing this topic.

diarmuid

  • Bull Frog
  • Posts: 417
Help window keeps activating....grrrrrrrrr
« on: February 24, 2011, 07:13:39 AM »
below is a piece of code that i run in a lisp in AutoCAD 2008.  For some reason and for the life of me i cannot figure out the hlep window is activated.
now it happens between the "An Equipment table has been added" alert box and the "Note 1 has been added to your drawing" alert box.  It must be something so silly.  Could anybody spot what i've done wrong?

Any help would be appreciated  :?

Regards

Diarmuid

Code: [Select]
(if     (and (not(tblsearch "block" "M-SPIDTABLE")) (= pmfolder "41" )(tblsearch "block" "TB-a1"))   
                (progn
                    (prompt "\nM-SPIDTABLE table not found, inserting...\n")
                    (command "-layer" "make" "M-0900A-V-----------PrimaryProcessEquipments-DrwTxt" "color" "210" "" "")
                    (command "-insert" "P:/ACAD/wkspc/BlockLib/M-SPIDTABLE" "9,585" "" "" "")
                    (command "zoom" "extents")
                    (Alert  "An Equipment table has been added")
                    (princ)
                );end progn
        );end if
       
        (prompt "\nEquipment table check OK...\n")
   
        (if (and (not(tblsearch "block" "M-SNOTE")) (= pmfolder "41" )(tblsearch "block" "TB-a1"))
                    (progn
                        (prompt "\nNote 1 not found..\n")
                        (command "-layer" "make" "M-0900A-V-----------PrimaryProcessEquipments-DrwTxt" "color" "210" "" "")
                        (command "-insert" "P:/ACAD/wkspc/BlockLib/M-SNTEBDY" "832,585" "" "" "")
                        (command "explode" "l" "")
                        (command "zoom" "extents")
                        (Alert  "Note 1 has been added to your drawing")
                        (setvar "cmdecho" 1)
                        (princ)
                    );end progn
                )

If you want to win something run the 100m, if you want to experience something run a marathon

Biscuits

  • Swamp Rat
  • Posts: 502
Re: Help window keeps activating....grrrrrrrrr
« Reply #1 on: February 24, 2011, 07:33:20 AM »
Code: [Select]
"color" "210" "" "")
should be?

 
Code: [Select]
"color" "210" "")

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help window keeps activating....grrrrrrrrr
« Reply #2 on: February 24, 2011, 07:42:52 AM »
As Biscuits points out, the problem is most likely caused by an extra set of "", meaning an extra 'Enter', causing the last command to be repeated (hence, if the code is run on a new drawing, the Help is opened).

I've just hacked this together as an example, as I would recommend you use entmake to create your layer/insert - its much faster and less troublesome (you don't have to think about OSnap etc):

Code: [Select]
(if
  (and
    (not (tblsearch "BLOCK" "M-SPIDTABLE"))
    (eq pmfolder "41")
    (tblsearch "BLOCK" "TB-a1")
    (setq block (findfile "P:\\ACAD\\wkspc\\BlockLib\\M-SPIDTABLE.dwg"))
    (progn
      (command "_.-insert" block) (command)
      (tblsearch "BLOCK" "M-SPIDTABLE")
    )
  )
  (progn
    (prompt "\nM-SPIDTABLE table not found, inserting...\n")

    (Layer  "M-0900A-V-----------PrimaryProcessEquipments-DrwTxt" 210)
    (Insert "M-SPIDTABLE" '(9.0 585.0 0.))
   
    (command "_.zoom" "_extents")
    (Alert "An Equipment table has been added")
    (princ)
  )
)

(defun Layer ( name colour )
  (entmake
    (list
      (cons 0 "LAYER")
      (cons 100 "AcDbSymbolTableRecord")
      (cons 100 "AcDbLayerTableRecord")
      (cons 2 name)
      (cons 70 0)
      (cons 62 colour)
    )
  )
)

(defun Insert ( name pt )
  (entmakex
    (list
      (cons 0  "INSERT")
      (cons 2  name)
      (cons 10 pt)
    )
  )
)

diarmuid

  • Bull Frog
  • Posts: 417
Re: Help window keeps activating....grrrrrrrrr
« Reply #3 on: February 24, 2011, 08:54:17 AM »
awsome stuff,  thanks for the spotting of the boo boo.

also , thanks for the extra pointers

Regards
Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon

diarmuid

  • Bull Frog
  • Posts: 417
Re: Help window keeps activating....grrrrrrrrr
« Reply #4 on: February 24, 2011, 11:08:28 AM »
Thanks for the help,

 :ugly:  This was in the wrong post

The reason i was getting the help window appearing was my code showed:

(command "explode" "l" "")

This was incorrect, the extra "" at the end was not needed. (sure when you type out the command you need an extra "enter" to exit the comment, but from inside a lisp you dont when you select "last".

Regards

Diarmuid

If you want to win something run the 100m, if you want to experience something run a marathon

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help window keeps activating....grrrrrrrrr
« Reply #5 on: February 24, 2011, 02:26:09 PM »
This behaviour with the 'explode' command is temperamental and can be dependent on the setting of the QAFLAGS System Variable (store the setting before messing with that).

If you're exploding Blocks, perhaps use the Explode method:

Code: [Select]
(vla-Explode (setq obj (vlax-ename->vla-object (entlast))))
(vla-delete obj)

Or, if using my 'Insert' subfunction:

Code: [Select]
(vla-Explode (setq obj (vlax-ename->vla-object (Insert "M-SPIDTABLE" '(9.0 585.0 0.)))))
(vla-delete obj)

Of course, the 'Insert' sub could be replaced by code that uses the InsertBlock method, but I didn't want to confuse you too much.  :|

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Help window keeps activating....grrrrrrrrr
« Reply #6 on: February 24, 2011, 03:06:27 PM »
FYI, if you use command -insert, you can prefix the name with "*" and it will insert the block exploded.
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help window keeps activating....grrrrrrrrr
« Reply #7 on: February 24, 2011, 03:07:30 PM »
FYI, if you use command -insert, you can prefix the name with "*" and it will insert the block exploded.

Ooo! Didn't know that - nice one Alan  :-)

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Help window keeps activating....grrrrrrrrr
« Reply #8 on: February 24, 2011, 03:12:53 PM »
FYI, if you use command -insert, you can prefix the name with "*" and it will insert the block exploded.

Ooo! Didn't know that - nice one Alan  :-)
Oh yeah, and an "=" suffix will overwrite an existing block definition.

eg. (what I use to insert our Dimension/MLeader/QLeader/TextStyle settings)
Code: [Select]
(defun CES_DimSettings (/)
  (command "_.insert" "CES-DIMSETUP=" nil)
  (command "_.purge" "_b" "CES-DIMSETUP" "_n")
  (princ)
)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help window keeps activating....grrrrrrrrr
« Reply #9 on: February 24, 2011, 04:02:21 PM »
FYI, if you use command -insert, you can prefix the name with "*" and it will insert the block exploded.

Ooo! Didn't know that - nice one Alan  :-)
Oh yeah, and an "=" suffix will overwrite an existing block definition.

Cheers mate  :-)

I haven't used the command version in so long that there is much to be learnt  :oops:

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: Help window keeps activating....grrrrrrrrr
« Reply #10 on: February 24, 2011, 04:11:48 PM »
FYI, if you use command -insert, you can prefix the name with "*" and it will insert the block exploded.

Ooo! Didn't know that - nice one Alan  :-)
Oh yeah, and an "=" suffix will overwrite an existing block definition.

Cheers mate  :-)

I haven't used the command version in so long that there is much to be learnt  :oops:
It has it's uses. About the only time I use it is when I want to see the block to either pick the insertion point or set the rotation while seeing the actual block rotating.

Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

diarmuid

  • Bull Frog
  • Posts: 417
Re: Help window keeps activating....grrrrrrrrr
« Reply #11 on: February 25, 2011, 03:56:14 AM »
Just another one as we are on the subject of blocks: Is there a way of redefining a block using without having to insert it.  Sometimes i wish to redefine a block but the next section of my code means i need to remove the "last" insertion of the block.

Diarmuid
If you want to win something run the 100m, if you want to experience something run a marathon