Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/18/2022 in all areas

  1. Yes, you modify the x-scale (assoc 41) or y-scale (assoc 42) to -1 (or to -1 times the current factor). The only thing: flipX will flip it based on the insert point. If the insert point were in the middle-left of the door block, then it would stay in place ... (defun flip_ (ent x y / sc) (if x (progn ;; read the current scale, then multiply be x ( = -1) (setq sc (cdr (assoc 41 (entget ent)))) (setq x (* x sc)) (entmod (subst (cons 41 x) ;; 256 sets the color to ByLayer (assoc 41 (entget ent)) ;; the current color (entget ent) )) ) ) (if y (progn ;; read the current scale, then multiply be y ( = -1) (setq sc (cdr (assoc 42 (entget ent)))) (setq y (* y sc)) (entmod (subst (cons 42 y) ;; 256 sets the color to ByLayer (assoc 42 (entget ent)) ;; the current color (entget ent) )) ) ) ) (defun c:flipx ( / ent) (setq ent (car (entsel "\nSelect door: "))) (flip_ ent -1 nil) ) (defun c:flipy ( / ent) (setq ent (car (entsel "\nSelect door: "))) (flip_ ent nil -1) )
    2 points
  2. that should work. Might be just as easy in the properties box to multiply the relevant axis by -1 (add a '-' or take it away). If I was doing a lot of drawings with doors I would look at it slightly differently, looking at entmake you can list all the objects that make up a door and create these as a block (minimum 2 lines and an arc, sometimes I also see the frame details too). Make a LIPS say "NewDoor", 3 clicks - hinge, other end of opening and direction to create a door block (if it doesn;t exist), scale and flip all in one go. can find out an example later maybe
    1 point
  3. Thank you very much for taking your time for the code ! now it's time for me to draw fast.
    1 point
  4. @Steven P my lisp skills are bad. I looked at the pedit command as you said. I tried with examples but I could only draw a line between the block and the line. @mhupp thank you for the code but when i try the code all blocks try to connect to the same point.
    1 point
  5. Wow. What a treat to see how you solved this. I was expecting something a bit more complicated, but your solution is easy to see and comprehend. Thanks for such an elegant solution. Steve
    1 point
  6. Simple enough Added a counter. If you don't like/want the found message just delete the 2nd alert line in the last if statement. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Original by LeeMac @ cadtutor.net 16 NOV 2010 ;; So long ago the saved link is broken. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Mod by SteveJ July 2022 to highlight all of specified OBJ TYPE. (defun c:OBJ (/ i ot ss attLst Box ul lr) (vl-load-com) (setq i 0) ;added line (setq ot (strcase (getstring "Enter OBJ TYPE to locate: "))) (if (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1)))) (progn (command "regen") ;erases current highlighting for next search. (foreach Obj (mapcar 'vlax-ename->vla-object (mapcar 'cadr (ssnamex ss))) (setq attLst nil) (foreach att (vlax-safearray->list (vlax-variant-value (vla-getAttributes Obj))) (setq attLst (cons (cons (vla-get-TagString att) (vla-get-TextString att)) attLst)) ) (if (and (assoc "OBJTYPE" attLst) (eq ot (cdr (assoc "OBJTYPE" attLst))) (setq Box (assoc "BOXSIZE" attLst) Box (read (cdr Box)) ) ) (progn (setq ul (list (car Box) (cadr Box)) lr (list (caddr Box) (cadddr Box)) ) (grvecs (list 1 lr (list (car lr) (cadr ul)) ;RIGHT 1 ul (list (car lr) (cadr ul)) ;TOP 1 lr (list (car ul) (cadr lr)) ;BOTTOM 1 ul (list (car ul) (cadr lr)) ;LEFT ) ) (setq i (1+ i)) ;added line ) ) ) ) (princ "\n<!> No Attributed Blocks Found <!>") ) (if (eq i 0) ;added if statement (alert (strcat "No Attributed Blocks Found With Object Type \"" ot "\"")) (alert (strcat "Found " (itoa i) " Attributed Blocks With Object Type \"" ot "\"")) ) (princ) )
    1 point
  7. This should get you what you want. insertion point of block needs to be in the middle of block. If you don't want to be asked about the radius or will always have the same chamfer distance change the first line of code (or (setq r (getdist (strcat "\nSet Radius [0.500]: "))) (setq r 0.500)) change to (setq r 0.500) ;chamfer dist of 0.500 0.500 ;;----------------------------------------------------------------------;; ;; CONNECT BLOCK TO LINE (defun c:foo (/ r ss blklst l1 sp ep mpt p1 p2 l2 cir p3 p4 p5) (or (setq r (getdist (strcat "\nSet Radius [0.500]: "))) (setq r 0.500)) (setq ss (ssget '((0 . "INSERT")))) (setq blklst (mapcar '(lambda (x) (list (cdr (assoc 10 (entget x))) x)) (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))))) (setq blklst ;sorts top down left to right from insertion point (mapcar 'cadr (vl-sort blklst '(lambda (a b) (if (equal (caar a) (caar b) 1e-6) (< (car (car a)) (car (car b))) (> (cadr (car a)) (cadr (car b))) ) ) ) ) ) (if (setq l1 (car (entsel "\nSelect Line: "))) (progn (setq sp (cdr (assoc 10 (setq x (entget l1)))) ep (cdr (assoc 11 x)) mpt (mapcar '/ (mapcar '+ sp ep) '(2 2 2)) ) (if (> (- (angle sp ep) pi) 0) (command "_.Rotate" l1 "" mpt 180) ) ) ) (setvar 'cmdecho 0) (foreach ent Blklst (setq p1 (vlax-get (vlax-ename->vla-object ent) 'InsertionPoint)) (setq p2 (vlax-curve-getclosestpointto (vlax-ename->vla-object l1) p1)) (entmake (list (cons 0 "LINE") (cons 10 p1) (cons 11 p2))) (setq l2 (entlast)) (entmake (list (cons 0 "CIRCLE") (cons 10 p2) (cons 40 r))) (setq cir (entlast)) (setq p3 (polar p2 (+ (angle p1 p2) (/ pi 2)) r)) (setq p4 (polar p2 (+ (angle p1 p2) pi) r)) (setq p5 (polar p2 (- (angle p1 p2) (/ pi 2)) r)) (command "TRIM" cir "") (command (list l1 p2)) (command (list l2 p2)) (command "") (entmake (list (cons 0 "LINE") (cons 10 p3) (cons 11 p4))) (entmake (list (cons 0 "LINE") (cons 10 p4) (cons 11 p5))) (entdel cir) ) (setvar 'cmdecho 1) (princ) )
    1 point
  8. Likewise, though my view is that a 'student asking for help' usually means you have an assignment to complete.. and I am not sure posting an full answer on here would help a lot - course tutors are able to look at the internet and it's forums as well..... Best we should do is offer hints, tips and answer specific questions (such as "why isn't this part working"). So if you can do it manually have you made up a LISP to do 1 block as a layout? Start off simple and just write the code to do it once, see if you can get that to work, then you can work on doing it for all blocks. Might be your process is: Select the block Get the block name Get the block 'bounding box', and it's coordinates Make a new Layout Tab and name it to the block name, set the paper size Make a view port to that paper size Zoom the view port to the bounding box coordinates Once you have the process written down - even simple like this - it is easier to go through each step and make it work. What looks like a complex problem is often a lot of simple problems all in a row. Then your question might change to "I have this LISP, selecting a block and it makes a layout, how can I alter it to select all blocks and make layouts from them all".. which might be a very simple answer
    1 point
×
×
  • Create New...