Jump to content

Recommended Posts

Posted
Ok cool thanks.

 

Is there any way to add something to the lisp so when I choose my insertion point it shows me the nea snap symbol. plus after the lisp is done all my snaps are gone. Is there a way to remember what snaps where active before the lisp and set them back ater the lisp is over?

  • Replies 29
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    17

  • neekcotrack

    12

  • David Bethel

    1

Top Posters In This Topic

Posted Images

Posted

With the Entsel method of finding the entity and the point, you are using the "pickbox" to select the entity and the point is retrieved afterwards, so to have the nearest symbol shown would require a different method of selecting the line.

 

As for the OSnaps - in your routine, the osnap will be reset back to whatever it was previously, providing the LISP is exited without error (or without the user hitting esc). - this is because your routine has no "error trap".

 

If you look at my posted routine (that works with lines at all angles), you will see the error trap near the top of the routine:

 

(defun *error*...

 

This resets all settings in the event of the user hitting Esc, or the LISP having an error.

Posted

Try this for the block insertion - you should now be able to use your nearest snap:

 

(defun c:hb  (/ *error* ovar vlst ent ip edata ang att1 blk ip1 ip2 ans)
 (defun *error*  (msg)
   (if    ovar (mapcar 'setvar vlst ovar))
   (princ (strcat "\nError: " (strcase msg))) (princ))
 (setq    vlst '("OSMODE" "BLIPMODE" "CMDECHO" "ATTDIA" "ATTREQ")
   ovar (mapcar 'getvar vlst))
 (if (or (tblsearch "BLOCK" "HBAB") (findfile "HBAB.dwg"))
   (progn
     (mapcar 'setvar vlst '(544 0 0 0 0))
     (while (and (setq ip  (getpoint "\nSelect Point for Block: ")
           ent (nentselp "" ip)))
   (setvar "OSMODE" 0)
   (setq edata (entget (car ent))
         ang   (angle (dxf 10 edata) (dxf 11 edata)))
   (command "-insert" "HBAB" "s" (max 1 (getvar "dimscale")) ip (* 180.0 (/ ang pi)))
   (setq att1 (entnext (setq blk (entlast)))
         ip1  (dxf 10 (entget att1))
         ip2  (dxf 10 (entget (entnext att1))))
   (command "Break" ent "f" ip1 ip2)
   (initget "Yes No")
   (setq ans (getkword "\nMirror Block? [Yes/No] <No>: "))
   (if (= ans "Yes")
     (command "_mirror" blk "" ip1 ip2 "_Y"))
   (setvar "OSMODE" 544)))
   (princ "\n<!> Block Not Found <!>"))
 (mapcar 'setvar vlst ovar)
 (princ))

(defun dxf  (code elist)
 (cdr (assoc code elist)))

Posted
Try this for the block insertion - you should now be able to use your nearest snap:

 

(defun c:hb  (/ *error* ovar vlst ent ip edata ang att1 blk ip1 ip2 ans)
 (defun *error*  (msg)
   (if    ovar (mapcar 'setvar vlst ovar))
   (princ (strcat "\nError: " (strcase msg))) (princ))
 (setq    vlst '("OSMODE" "BLIPMODE" "CMDECHO" "ATTDIA" "ATTREQ")
   ovar (mapcar 'getvar vlst))
 (if (or (tblsearch "BLOCK" "HBAB") (findfile "HBAB.dwg"))
   (progn
     (mapcar 'setvar vlst '(544 0 0 0 0))
     (while (and (setq ip  (getpoint "\nSelect Point for Block: ")
           ent (nentselp "" ip)))
   (setvar "OSMODE" 0)
   (setq edata (entget (car ent))
         ang   (angle (dxf 10 edata) (dxf 11 edata)))
   (command "-insert" "HBAB" "s" (max 1 (getvar "dimscale")) ip (* 180.0 (/ ang pi)))
   (setq att1 (entnext (setq blk (entlast)))
         ip1  (dxf 10 (entget att1))
         ip2  (dxf 10 (entget (entnext att1))))
   (command "Break" ent "f" ip1 ip2)
   (initget "Yes No")
   (setq ans (getkword "\nMirror Block? [Yes/No] <No>: "))
   (if (= ans "Yes")
     (command "_mirror" blk "" ip1 ip2 "_Y"))
   (setvar "OSMODE" 544)))
   (princ "\n<!> Block Not Found <!>"))
 (mapcar 'setvar vlst ovar)
 (princ))

(defun dxf  (code elist)
 (cdr (assoc code elist)))

 

Ok I like it, but can I get it to let me choose my two point. One for insertion point and the other to specify the angle. I like that way.

Posted

Try this:

 

(defun c:hb  (/ *error* ovar vlst ent ip edata att1 blk ip1 ip2 ans)
 (defun *error*  (msg)
   (if    ovar (mapcar 'setvar vlst ovar))
   (princ (strcat "\nError: " (strcase msg)))
   (princ))
 (setq    vlst '("OSMODE" "BLIPMODE" "CMDECHO" "ATTDIA" "ATTREQ")
   ovar (mapcar 'getvar vlst))
 (if (or (tblsearch "BLOCK" "HBAB") (findfile "HBAB.dwg"))
   (progn
     (mapcar 'setvar vlst '(544 0 0 0 0))
     (while (and (setq    ip  (getpoint "\nSelect Point for Block: ")
           ent (nentselp "" ip)))
   (setvar "OSMODE" 0)
   (setq edata (entget (car ent)))
   (command "-insert" "HBAB" "s" (max 1 (getvar "dimscale")) ip pause)
   (setq att1 (entnext (setq blk (entlast)))
         ip1  (dxf 10 (entget att1))
         ip2  (dxf 10 (entget (entnext att1))))
   (command "Break" ent "f" ip1 ip2)
   (initget "Yes No")
   (setq ans (getkword "\nMirror Block? [Yes/No] <No>: "))
   (if (= ans "Yes")
     (command "_mirror" blk "" ip1 ip2 "_Y"))
   (setvar "OSMODE" 544)))
   (princ "\n<!> Block Not Found <!>"))
 (mapcar 'setvar vlst ovar)
 (princ))

(defun dxf  (code elist)
 (cdr (assoc code elist)))

Posted
Try this:

 

(defun c:hb  (/ *error* ovar vlst ent ip edata att1 blk ip1 ip2 ans)
 (defun *error*  (msg)
   (if    ovar (mapcar 'setvar vlst ovar))
   (princ (strcat "\nError: " (strcase msg)))
   (princ))
 (setq    vlst '("OSMODE" "BLIPMODE" "CMDECHO" "ATTDIA" "ATTREQ")
   ovar (mapcar 'getvar vlst))
 (if (or (tblsearch "BLOCK" "HBAB") (findfile "HBAB.dwg"))
   (progn
     (mapcar 'setvar vlst '(544 0 0 0 0))
     (while (and (setq    ip  (getpoint "\nSelect Point for Block: ")
           ent (nentselp "" ip)))
   (setvar "OSMODE" 0)
   (setq edata (entget (car ent)))
   (command "-insert" "HBAB" "s" (max 1 (getvar "dimscale")) ip pause)
   (setq att1 (entnext (setq blk (entlast)))
         ip1  (dxf 10 (entget att1))
         ip2  (dxf 10 (entget (entnext att1))))
   (command "Break" ent "f" ip1 ip2)
   (initget "Yes No")
   (setq ans (getkword "\nMirror Block? [Yes/No] <No>: "))
   (if (= ans "Yes")
     (command "_mirror" blk "" ip1 ip2 "_Y"))
   (setvar "OSMODE" 544)))
   (princ "\n<!> Block Not Found <!>"))
 (mapcar 'setvar vlst ovar)
 (princ))

(defun dxf  (code elist)
 (cdr (assoc code elist)))

 

Perfect! How would I use the same lisp but use it without the mirroring in there? This will be for a different block.

 

I tried just taking out this:

 

(initget "Yes No")

(setq ans (getkword "\nMirror Block? [Yes/No] : "))

(if (= ans "Yes")

(command "_mirror" blk "" ip1 ip2 "_Y"))

 

but my i lost my snaps like before.

Posted

You have removed the correct lines - but this shouldn't affect your snaps.

 

Make sure you have all your snaps how you want them before running the LISP - the LISP only retrieves the settings of the snaps and replaces these settings after it is run, so there should be no problems with the snaps.

 

Lee

Posted
You have removed the correct lines - but this shouldn't affect your snaps.

 

Make sure you have all your snaps how you want them before running the LISP - the LISP only retrieves the settings of the snaps and replaces these settings after it is run, so there should be no problems with the snaps.

 

Lee

 

It's woking now. I don't know what happened :?

Posted

Probably after running your old LISP with no Error Trap, your OSMODE was set to 0, so, when running my LISP, the Error Trap reset the OSMODE back to its original value of 0.

 

But, glad it works for you now :)

 

Lee

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...