0 Members and 2 Guests are viewing this topic.
(defun c:test(/ LowerLeft LastEnt NewEnts) (vl-load-com);; CAB version 03.01.2008;; returns a list of enames and not a selection set.;; CAB - get last entity in datatbase;; An entity name, or nil, if there are no entities in the current drawing.(defun GetLastEnt ( / ename result ) (if (setq result (entlast)) (while (setq ename (entnext result)) (setq result ename) ) ) result);; CAB 09.17.08 - return a list of new enames;; if ename is nil then return all objects in DWG(defun GetNewEntities (ename / new) (cond ((or (null ename) (null (setq new (list (entnext)))))) ((eq 'ENAME (type ename)) (while (setq ename (entnext ename)) (if (entget ename) (setq new (cons ename new))) ) ) ; ((alert "Ename wrong type.")) ) new) ;; returns a point list in WCS coordinates ((lower left)(upper right)) (defun boundingbox (lst / ptlst mnpt mxpt) (mapcar '(lambda (x) (vla-getboundingbox (vlax-ename->vla-object x) 'mnpt 'mxpt) (setq ptlst (cons (vlax-safearray->list mnpt) ptlst)) (setq ptlst (cons (vlax-safearray->list mxpt) ptlst)) ) lst ) ;;following by Tony Tanzillo (list (apply 'mapcar (cons 'min ptlst)) (apply 'mapcar (cons 'max ptlst)) ) ) (setq LastEnt (GetLastEnt)) (c:eMake) (setq NewEnts (vl-remove-if '(lambda(x) (= "VIEWPORT" (cdr (assoc 0 (entget x))))) (GetNewEntities LastEnt))) (setq LowerLeft (car (boundingbox NewEnts))) (command "._move") (mapcar 'command NewEnts) (command "" "_non" LowerLeft))
Creation of hatch with the instruction of a pattern, a angle and scale.Code: [Select](defun entmakex-hatch (L a n s) ;; By ElpanovEvgeniy ;; L - list point ;; A - angle hatch ;; N - name pattern ;; S - scale ;; returne - hatch ename (entmakex (apply 'append (list (list '(0 . "HATCH") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbHatch") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)[color=red] '(2 . "ANSI31")[/color] (if (= n "SOLID") '(70 . 1) '(70 . 0) ) ;_ if '(71 . 0) (cons 91 (length l)) ) ;_ list (apply 'append (mapcar '(lambda (a) (apply 'append (list (list '(92 . 7) '(72 . 0) '(73 . 1) (cons 93 (length a))) (mapcar '(lambda (b) (cons 10 b)) a) '((97 . 0)) ) ;_ list ) ;_ apply ) ;_ lambda l ) ;_ mapcar ) ;_ apply (list '(75 . 0) '(76 . 1) (cons 52 a) (cons 41 s) '(77 . 0) '(78 . 1) (cons 53 a) '(43 . 0.) '(44 . 0.) '(45 . 1.) '(46 . 1.) '(79 . 0) '(47 . 1.) '(98 . 2) '(10 0. 0. 0.0) '(10 0. 0. 0.0) '(451 . 0) '(460 . 0.0) '(461 . 0.0) '(452 . 1) '(462 . 1.0) '(453 . 2) '(463 . 0.0) '(463 . 1.0) '(470 . "LINEAR") ) ;_ list ) ;_ list ) ;_ apply ) ;_ entmakex) ;_ defun
(defun entmakex-hatch (L a n s) ;; By ElpanovEvgeniy ;; L - list point ;; A - angle hatch ;; N - name pattern ;; S - scale ;; returne - hatch ename (entmakex (apply 'append (list (list '(0 . "HATCH") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbHatch") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0)[color=red] '(2 . "ANSI31")[/color] (if (= n "SOLID") '(70 . 1) '(70 . 0) ) ;_ if '(71 . 0) (cons 91 (length l)) ) ;_ list (apply 'append (mapcar '(lambda (a) (apply 'append (list (list '(92 . 7) '(72 . 0) '(73 . 1) (cons 93 (length a))) (mapcar '(lambda (b) (cons 10 b)) a) '((97 . 0)) ) ;_ list ) ;_ apply ) ;_ lambda l ) ;_ mapcar ) ;_ apply (list '(75 . 0) '(76 . 1) (cons 52 a) (cons 41 s) '(77 . 0) '(78 . 1) (cons 53 a) '(43 . 0.) '(44 . 0.) '(45 . 1.) '(46 . 1.) '(79 . 0) '(47 . 1.) '(98 . 2) '(10 0. 0. 0.0) '(10 0. 0. 0.0) '(451 . 0) '(460 . 0.0) '(461 . 0.0) '(452 . 1) '(462 . 1.0) '(453 . 2) '(463 . 0.0) '(463 . 1.0) '(470 . "LINEAR") ) ;_ list ) ;_ list ) ;_ apply ) ;_ entmakex) ;_ defun
(defun entmakex-hatch (L a n s);; By ElpanovEvgeniy;; L - list of list point. like ((pt11 pt12 pt13)(pt21 pt22 pt23));; A - angle hatch;; N - name pattern;; S - scale;; returne - hatch ename;;USE;|(entmakex-hatch '(((538.794 584.563) (895.629 584.563) (895.629 997.377) (538.794 997.377)) ((386.809 345.13) (670.955 345.13) (670.955 855.369) (386.809 855.369)) ) (/ pi 2) "ANSI31" 2.) ;_ entmakex-hatch(entmakex-hatch(list (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel "\nSelect Polyline:")))))) ;_ list(/ pi 2)"SOLID"2.)(entmakex-hatch(list (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel "\nSelect Polyline:")))))) ;_ list(/ pi 2)"ANSI31"2.)(entmakex-hatch(list (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel "\nSelect Polyline:")))))) ;_ list(/ pi 2)"ANSI32"2.)|;(entmakex (apply 'append (list (list '(0 . "HATCH") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbHatch") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0) (cons 2 n) (if (= n "SOLID") '(70 . 1) '(70 . 0) ) ;_ if '(71 . 0) (cons 91 (length l)) ) ;_ list (apply 'append (mapcar '(lambda (a) (apply 'append (list (list '(92 . 7) '(72 . 0) '(73 . 1) (cons 93 (length a))) (mapcar '(lambda (b) (cons 10 b)) a) '((97 . 0)) ) ;_ list ) ;_ apply ) ;_ lambda l ) ;_ mapcar ) ;_ apply (if (= n "SOLID") (list '(75 . 0) '(76 . 1);;; (cons 52 a);;; (cons 41 s);;; '(77 . 0);;; '(78 . 1);;; (cons 53 a);;; '(43 . 0.);;; '(44 . 0.);;; '(45 . 1.);;; '(46 . 1.);;; '(79 . 0) '(47 . 1.) '(98 . 2) '(10 0. 0. 0.0) '(10 0. 0. 0.0) '(450 . 0) '(451 . 0) '(460 . 0.0) '(461 . 0.0) '(452 . 0) '(462 . 0.0) '(453 . 2) '(463 . 0.0) '(63 . 256) '(463 . 1.0) '(63 . 256) '(470 . "LINEAR") ) ;_ list (list '(75 . 0) '(76 . 1) (cons 52 a) (cons 41 s) '(77 . 0) '(78 . 1) (cons 53 a) '(43 . 0.) '(44 . 0.) '(45 . 1.) '(46 . 1.) '(79 . 0) '(47 . 1.) '(98 . 2) '(10 0. 0. 0.0) '(10 0. 0. 0.0);;; '(451 . 0);;; '(460 . 0.0);;; '(461 . 0.0);;; '(452 . 1);;; '(462 . 1.0);;; '(453 . 2);;; '(463 . 0.0);;; '(463 . 1.0) '(470 . "LINEAR") ) ;_ list ) ) ;_ list ) ;_ apply) ;_ entmakex) ;_ defun
(entmakex-hatch(list (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel "\nSelect Polyline:")))))) ;_ list(/ pi 2)"SOLID"2.)(entmakex-hatch(list (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel "\nSelect Polyline:")))))) ;_ list(/ pi 2)"ANSI31"2.)(entmakex-hatch(list (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel "\nSelect Polyline:")))))) ;_ list(/ pi 2)"ANSI32"2.)
Glad to help. Enjoy your stay here at the Swamp.