neekcotrack Posted March 18, 2009 Posted March 18, 2009 I have a lisp that I have modified from www.afralisp.net and It does everything thing I want now but I can't figure out how to ask the user if they would like to mirror the block! I want it to happen after the block is placed so you can see the block there. The example for it is the hosebib with the HB next to it, see how it is upsidedown. (command "Insert" "HBAB" "s" (getvar "dimscale") ip pause pause "" "") I think I would change the pauses to points and use those as the line I mirror off of, but I have never done this so I have no clue how to make those in to point to reference. If some can help I will be so thankful!!!! Quote
Lee Mac Posted March 18, 2009 Posted March 18, 2009 I'm not sure where your insertion point on the block is, but when I had a P&ID LISP, I used rotate to flip the block, just using the ip as the base point: (command "_rotate" (entlast) "" ip "180") Quote
Lee Mac Posted March 18, 2009 Posted March 18, 2009 Or, maybe with an option for the user: (initget "Yes No") (setq ans (getkword "\nRotate Block? [Yes/No] <No>: ")) (if (= ans "Yes") (command "_rotate" (entlast) "" ip "180.0")) Quote
David Bethel Posted March 18, 2009 Posted March 18, 2009 The standard way to mirror an INSERT is to change DXF group 41 to the negative of it's current value. -David Quote
neekcotrack Posted March 18, 2009 Author Posted March 18, 2009 I'm not sure where your insertion point on the block is, but when I had a P&ID LISP, I used rotate to flip the block, just using the ip as the base point: (command "_rotate" (entlast) "" ip "180") I think I said it wrong sorry. Below is another picture. I have a block that is magenta and I need it to ask if I like to mirror it after it places it. My insertion point is P1 and P2 is the second point that determines the angle of the block. I need it to ask if I like to mirror the block along P1 and P2 and get the end result of the gray block next to the magenta block. I hope this helps!!!! Quote
Lee Mac Posted March 18, 2009 Posted March 18, 2009 Well then maybe: (initget "Yes No") (setq ans (getkword "\nMirror Block? [Yes/No] <No>: ")) (if (= ans "Yes") (command "_mirror" (entlast) p1 p2 "n")) Quote
neekcotrack Posted March 18, 2009 Author Posted March 18, 2009 I run the lisp hosebib. It ask for insertion point (that is going to be p1 in example 1) and then requires a second point to define the angle of the block. (that is going to be the p2 on in example 1). When that is done the finished running lisp looks like example 2. I want it to know ask "Mirror Block?" [Yes/No]. If I hit yes the end product will look like example 3 using p1 and p2 at the mirror line points. If I hit no it will cancel out and do nothing. I hope this helps on what I am looking for. HoseBib.lsp Quote
Lee Mac Posted March 18, 2009 Posted March 18, 2009 Upon looking at your LISP, it seems you are only allowing for horizontal lines - is this how you would like it to remain? Also, there is a much simpler method for breaking the lines, without the use of attributes, if you know the exact length of the block you are inserting and your base point is one of the break points (which it is), then there's no need to delve into attributes which could lead to potential errors. Lee Quote
Lee Mac Posted March 18, 2009 Posted March 18, 2009 I think the LISP that you have at the moment could be simplified to this: (defun c:hb2 (/ vlst ovar ent1 ip ent2 ip1 ip2 att1) (setq vlst '("OSMODE" "BLIPMODE" "CMDECHO" "ATTDIA" "ATTREQ") ovar (mapcar 'getvar vlst)) (mapcar 'setvar vlst '(544 0 0 0 0)) (while (and (setq ent1 (entsel "\nSelect Block Insertion Point") ip (osnap (cadr ent1) "_nea"))) (setvar "OSMODE" 0) (setq ent2 (car ent1)) (command "-insert" "HBAB" "s" (max 1 (getvar "dimscale")) ip "") (setq att1 (entnext (entlast)) ip1 (cdr (assoc 10 (entget att1))) ip2 (cdr (assoc 10 (entget (entnext att1))))) (command "_break" ent1 "f" ip1 ip2) (setvar "OSMODE" 544)) (mapcar 'setvar vlst ovar) (princ)) Quote
Lee Mac Posted March 19, 2009 Posted March 19, 2009 However, this could be used for lines at any angle: (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)) (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 (setq ent (entsel "\nSelect Block Insertion Point")) (setq ip (osnap (cadr ent) "_nea")) (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))) Error Trapping included also to check for block name, and mirror option added. Quote
neekcotrack Posted March 19, 2009 Author Posted March 19, 2009 Can I keep the lisp the same as I have in line 7 for now and just add the mirror yes or no question thanks. I just want to stick with that for now because its what I know right now. Quote
Lee Mac Posted March 19, 2009 Posted March 19, 2009 Well, I suppose you can do, but there is a lot in that LISP which is unnecessary, and it will only work with horizontal lines. - but I will alter it as you wish. Quote
Lee Mac Posted March 19, 2009 Posted March 19, 2009 With mirror option added: (defun c:HB ( / oldsnap ip ent1 ent2 ep1 ep2 edata ip1 ip2) (setq oldsnap (getvar "OSMODE")) ;get the current snap (setvar "OSMODE" 544) ;set snap to intersection and nearest (setvar "BLIPMODE" 0) ;switch blips off (setvar "CMDECHO" 0) ;switch command echo off (while ;while an insertion point is selected (setq ent1 (entsel "\nSelect Block Insertion Point") ip (osnap (cadr ent1) "_nea")) (setvar "OSMODE" 0) ;switch the snap off (setq ent2 (entget (car ent1))) ;get the entity data of the line (setq ep1 (cdr (assoc 10 ent2))) ;get the first end point (setq ep2 (cdr (assoc 11 ent2))) ;get the second end point (setvar "ATTDIA" 0) ;switch off the attribute dialog box (command "Insert" "HBAB" "s" (getvar "dimscale") ip pause pause "" "") ;insert the block (setq edata (entget (setq en (entlast)))) ;get the block entity data (setq edata (entget (entnext (dxf -1 edata)))) ;get the attribute entity list (setq ip1 (dxf 10 edata)) ;extract the first attribute insertion point (setq edata (entget (entnext (dxf -1 edata)))) ;get the next attribute entity list (setq ip2 (dxf 10 edata)) ;extract the second attribute insertion point (command "Break" ent1 "f" ip1 ip2) ;break the line (initget "Yes No") (setq ans (getkword "\nMirror Block? [Yes/No] <No>: ")) (if (= ans "Yes") (command "_mirror" en "" ip1 ip2 "_Y")) (setvar "OSMODE" 544) ;switch snap back on );while (setvar "OSMODE" oldsnap) ;reset snap (setvar "BLIPMODE" 1) ;switch blips back on (setvar "CMDECHO" 1) ;switch command echo back on (setvar "ATTDIA" 1) ;switch attribute dialog boc back on (princ) ;finish clean );defun ;;;********************************************************** (defun dxf (code elist) (cdr (assoc code elist)) );defun (princ) Quote
neekcotrack Posted March 19, 2009 Author Posted March 19, 2009 What do you mean by horizantal lines? Quote
Lee Mac Posted March 19, 2009 Posted March 19, 2009 Well, you are finding the start and end points of the line, (cdr (assoc 10.. (cdr (assoc 11.., but then you are not doing anything with these. I would assume that you would want to find the angle of the line, so that you could insert the block at the correct angle to the line. Quote
neekcotrack Posted March 19, 2009 Author Posted March 19, 2009 Well, you are finding the start and end points of the line, (cdr (assoc 10.. (cdr (assoc 11.., but then you are not doing anything with these. I would assume that you would want to find the angle of the line, so that you could insert the block at the correct angle to the line. It am doing that with one of my blocks but there are some I am not because I have the block at 0 degrees and othere times 180 degrees so it is just easier to pick the insertion point and select a point on on the line to get the angle for this block. Quote
Lee Mac Posted March 19, 2009 Posted March 19, 2009 Oh, so this LISP is one of many, but it just so happens that with this LISP, you only ever want the block at either 0, or 180 degrees. Am I correct? Quote
neekcotrack Posted March 19, 2009 Author Posted March 19, 2009 Oh, so this LISP is one of many, but it just so happens that with this LISP, you only ever want the block at either 0, or 180 degrees. Am I correct? These blocks will go on pipe, so it can be at a lot of angles. So it is easier to just two point angle pick. Quote
Lee Mac Posted March 19, 2009 Posted March 19, 2009 Ok, your choice If you need any other help, just let me know Quote
neekcotrack Posted March 19, 2009 Author Posted March 19, 2009 Ok, your choice If you need any other help, just let me know Ok cool thanks. 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.