cadman2009 Posted November 28, 2009 Posted November 28, 2009 Hi I want make a script file for drawing many lines and text , and a part of this file must use of hatch command and then hatches inside many closed polylines , and my problem is that I want write many commands that without picking on object , make it for me . please tell me , How I can hatch inside a polygon without picking for select object , by use of scripts commands . Quote
Lee Mac Posted November 28, 2009 Posted November 28, 2009 You can use a call to a LISP function within your script - just create a LISP to hatch your polylines. It helps if they have some defining characteristic - i.e. are all on the same layer, etc. Lee Quote
Lee Mac Posted November 28, 2009 Posted November 28, 2009 As an example: (defun hpoly (/ *error* vl ov i ss ent) (defun *error* (msg) (and ov (mapcar 'setvar vl ov)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl)) (mapcar 'setvar vl '(0 0)) (if (setq i -1 ss (ssget "_X" '((0 . "*POLYLINE") (8 . "0") (-4 . "&") (70 . 1)))) (while (setq ent (ssname ss (setq i (1+ i)))) (command "_.-bhatch" "_P" "_USER" 45 5.0 "_N" "_S" ent "" ""))) (mapcar 'setvar vl ov) (princ)) The above will hatch all closed Polylines/LWPolylines. You can call it in a script (as long as it is loaded either in Startup Suite or ACADDOC.lsp), like this: open "C:\\Documents.... ..dwg" [color=Red][b](hpoly)[/b][/color] save.... Hope this helps, Lee Quote
cadman2009 Posted November 28, 2009 Author Posted November 28, 2009 As an example: (defun hpoly (/ *error* vl ov i ss ent) (defun *error* (msg) (and ov (mapcar 'setvar vl ov)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ)) (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl)) (mapcar 'setvar vl '(0 0)) (if (setq i -1 ss (ssget "_X" '((0 . "*POLYLINE") (8 . "0") (-4 . "&") (70 . 1)))) (while (setq ent (ssname ss (setq i (1+ i)))) (command "_.-bhatch" "_P" "_USER" 45 5.0 "_N" "_S" ent "" ""))) (mapcar 'setvar vl ov) (princ)) The above will hatch all closed Polylines/LWPolylines. You can call it in a script (as long as it is loaded either in Startup Suite or ACADDOC.lsp), like this: open "C:\\Documents.... ..dwg" [color=Red][b](hpoly)[/b][/color] save.... Hope this helps, Lee Thanks Lee , I use it and write you later that whats happend. Quote
Lee Mac Posted November 28, 2009 Posted November 28, 2009 Thanks Lee , I use it and write you later that whats happend. You're welcome Cadman, but also try to understand what each line is doing in the code, so that you may write your own code in the future. Lee 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.