CAD_Noob Posted March 10, 2020 Posted March 10, 2020 (edited) I have received a drawing wherein all walls are wide polylines (polylines with Global Width). I need to convert them all to proper polylines and hatch them with Ansi31. I found @Lee Mac's Polyline Outline which is working great. However, is it possible to select by windowing? coz current it is by single selection only and convert the "solid" into Ansi31 hatch? Edited March 10, 2020 by CAD_Noob Quote
Jonathan Handojo Posted March 10, 2020 Posted March 10, 2020 Um... there are two commands in there: Polyoutline and MPolyoutline. You might want to use MPolyoutline. 1 Quote
Lee Mac Posted March 10, 2020 Posted March 10, 2020 Thanks @Jonathan Handojo. To echo Jonathan's suggestion: the MPOLYOUTLINE custom command will the user offer a standard ssget selection prompt, or alternatively, you can define your own custom command to call the underlying LM:PolyOutline function with an entity name argument. Note that my Polyline Outline program is only compatible with linear segmented polylines - if your polylines contain non-linear segments, you may wish to use my Advanced Polyline Outline program. 1 Quote
Jonathan Handojo Posted March 10, 2020 Posted March 10, 2020 (edited) Technically, since Lee Mac used entmakex at the end, you can do: (setq ss (ssget '((0 . "*POLYLINE")))) (if ss (progn (foreach x (JH:selset-to-list ss) ... do your hatch on (LM:PolyOutline x) (entdel x) ) ) ) given (defun JH:selset-to-list (selset / lst iter) ; Returns all entities within a selection set into a list. (setq iter 0) (repeat (sslength selset) (setq lst (cons (ssname selset iter) lst) iter (1+ iter)) ) (reverse lst) ) Edited March 10, 2020 by Jonathan Handojo 1 Quote
Jim Clayton Posted March 10, 2020 Posted March 10, 2020 this MIGHT work...emphasis on the MIGHT showpstyle.LSP 1 Quote
CAD_Noob Posted March 11, 2020 Author Posted March 11, 2020 (edited) I missed the mPolyOutline command sorry. I just tried @Jim Clayton attached lisp but it did nothing. @Jonathan Handojo how do i use that? i need to edit Lee's code is it? under which part will i put that in? sorry I'm not very knowledgeable in lisp... Edited March 11, 2020 by CAD_Noob Quote
Jim Clayton Posted March 11, 2020 Posted March 11, 2020 yeah felt there was about a 10% chance of that being successful Quote
Jonathan Handojo Posted March 11, 2020 Posted March 11, 2020 10 hours ago, CAD_Noob said: I missed the mPolyOutline command sorry. I just tried @Jim Clayton attached lisp but it did nothing. @Jonathan Handojo how do i use that? i need to edit Lee's code is it? under which part will i put that in? sorry I'm not very knowledgeable in lisp... (defun test ( / pl ss) (setq ss (ssget '((0 . "*POLYLINE")))) (if ss (progn (foreach x (JH:selset-to-list ss) (setq pl (LM:PolyOutline x)) ;...do your hatch here (entdel x) ) ) ) ) Like that Quote
CAD_Noob Posted March 12, 2020 Author Posted March 12, 2020 9 hours ago, Jonathan Handojo said: (defun test ( / pl ss) (setq ss (ssget '((0 . "*POLYLINE")))) (if ss (progn (foreach x (JH:selset-to-list ss) (setq pl (LM:PolyOutline x)) ;...do your hatch here (entdel x) ) ) ) ) Like that Thanks...will try this one. Quote
CAD_Noob Posted March 12, 2020 Author Posted March 12, 2020 10 hours ago, Jonathan Handojo said: (defun test ( / pl ss) (setq ss (ssget '((0 . "*POLYLINE")))) (if ss (progn (foreach x (JH:selset-to-list ss) (setq pl (LM:PolyOutline x)) ;...do your hatch here (entdel x) ) ) ) ) Like that Maybe something wrong with the hatch part coz it's generating the polyline outline, not deleting/replacing the LWPOLYLINE into hatch... this is what i did, kindly correct the mistake i did. (defun c:test ( / pl ss hpn hps) (setq HPN (getvar 'HPNAME)) (setq HPS (getvar 'HPSCALE)) (setvar 'HPNAME "ANSI31") (setvar 'HPSCALE 5) (setq ss (ssget '((0 . "*POLYLINE")))) (if ss (progn (foreach x (JH:selset-to-list ss) (setq pl (LM:PolyOutline x)) (command "._hatch" ss "") ;...do your hatch here (entdel x) ) ) ) (setvar 'hpname hpn) (setvar 'hpscale hps) (princ) ) ;;------------------ (defun JH:selset-to-list (selset / lst iter) ; Returns all entities within a selection set into a list. (setq iter 0) (repeat (sslength selset) (setq lst (cons (ssname selset iter) lst) iter (1+ iter)) ) (reverse lst) ) ;;------------------=={ LWPolyline Outline }==----------------;; ;; ;; ;; Creates an LWPolyline surrounding the boundary of an ;; ;; LWPolyline with varying widths. Currently restricted to ;; ;; LWPolyline vertices with zero bulge. ;; ;;------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2011 - www.lee-mac.com ;; ;;------------------------------------------------------------;; ;; Arguments: ;; ;; ent - Entity name of LWPolyline ;; ;;------------------------------------------------------------;; ;; Returns: List of Entity name(s) of outline LWPolyline(s) ;; ;;------------------------------------------------------------;; (defun LM:PolyOutline ( ent / _vertices lst ) (defun _vertices ( e ) (if (setq e (member (assoc 10 e) e)) (cons (list (cdr (assoc 10 e)) (cdr (assoc 40 e)) (cdr (assoc 41 e)) ) (_vertices (cdr e)) ) ) ) (setq ent (entget ent) lst (_vertices ent) lst (apply 'mapcar (cons (function (lambda ( a b ) ( (lambda ( c ) (mapcar (function (lambda ( d ) (mapcar (function (lambda ( e f ) (mapcar 'd (car e) (mapcar (function (lambda ( g ) (* g (/ f 2.0))) ) c ) ) ) ) (list a b) (cdr a) ) ) ) (list + -) ) ) ( (lambda ( v / n ) (setq v (list (- (cadr v)) (car v) 0.0) n (distance '(0. 0.) v) ) (if (equal 0.0 n 1e-14) (list 0.0 0.0 0.0) (mapcar '/ v (list n n n)) ) ) (mapcar '- (car a) (car b)) ) ) ) ) (if (= 1 (logand 1 (cdr (assoc 70 ent)))) (list (cons (last lst) lst) (append lst (list (car lst))) ) (list lst (cdr lst)) ) ) ) lst ( (lambda ( a ) (if (zerop (logand 1 (cdr (assoc 70 ent)))) (append (list (mapcar 'car (car lst))) a (list (mapcar 'cadr (last lst))) ) a ) ) (apply 'append (mapcar (function (lambda ( a b / c ) (if (setq c (apply 'append (mapcar (function (lambda ( d e / f ) (if (setq f (inters (car d) (cadr d) (car e) (cadr e) nil)) (list f) ) ) ) a b ) ) ) (list c) ) ) ) lst (cdr lst) ) ) ) ) (mapcar (function (lambda ( a ) (entmakex (append (subst (cons 43 0.0) (assoc 43 ent) (subst (cons 70 (logior 1 (cdr (assoc 70 ent)))) (assoc 70 ent) (subst (cons 90 (length a)) (assoc 90 ent) (reverse (member (assoc 39 ent) (reverse ent))) ) ) ) (mapcar '(lambda ( p ) (cons 10 p)) a) (list (assoc 210 ent)) ) ) ) ) ( (lambda ( a b ) (if (zerop (logand 1 (cdr (assoc 70 ent)))) (list (append (if (equal (car a) (last b) 1e-8) (setq a (cdr a)) a ) (if (equal (car b) (last a) 1e-8) (setq b (cdr b)) b ) ) ) (list a b) ) ) (mapcar 'car lst) (reverse (mapcar 'cadr lst)) ) ) ) (princ) Quote
Jonathan Handojo Posted March 12, 2020 Posted March 12, 2020 (edited) 41 minutes ago, CAD_Noob said: (command "._hatch" ss "") (command "._hatch" pl "") You're simply replacing your old polyline into a new outline of the polyline by Lee Mac's routine, then hatching that resulted outline, and finally deleting the old polyline itself. Edited March 12, 2020 by Jonathan Handojo Quote
CAD_Noob Posted March 12, 2020 Author Posted March 12, 2020 1 hour ago, Jonathan Handojo said: (command "._hatch" pl "") You're simply replacing your old polyline into a new outline of the polyline by Lee Mac's routine, then hatching that resulted outline, and finally deleting the old polyline itself. It didn't hatch. It only created the polyline outline and deleted the wide polyline Quote
Jonathan Handojo Posted March 12, 2020 Posted March 12, 2020 (edited) 1 hour ago, CAD_Noob said: It didn't hatch. It only created the polyline outline and deleted the wide polyline My mistake... (command "_HATCH" "Solid" pl "") But that depends on the hatch style. The above shows Solid, but you want ANSI31, so instead of solid, it should be "ANSI31" You can try typing (command "_HATCH") straight on the command line... you'll see the following argument types it accepts. Ultimately, it's (command "_HATCH" "ANSI31" 1 0 pl "") Edited March 12, 2020 by Jonathan Handojo Quote
CAD_Noob Posted March 19, 2020 Author Posted March 19, 2020 On 3/12/2020 at 12:11 PM, Jonathan Handojo said: My mistake... (command "_HATCH" "Solid" pl "") But that depends on the hatch style. The above shows Solid, but you want ANSI31, so instead of solid, it should be "ANSI31" You can try typing (command "_HATCH") straight on the command line... you'll see the following argument types it accepts. Ultimately, it's (command "_HATCH" "ANSI31" 1 0 pl "") still can't get this to work 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.