Jump to content

Recommended Posts

Posted

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 .

Posted

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

Posted

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

Posted
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.

Posted
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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...