Jump to content

Hatch command Lisp


Saqib_theleo

Recommended Posts

Hello everyone,

I want a simple hatch Lisp which can select more than one objects and apply hatch. I tried this but it is only selecting one object and apply hatch to it.

(Defun C:HH ()
 (Command "-HATCH" "S" PAUSE "" "")
)

 

Link to comment
Share on other sites

Try this. keeps pausing to allow you to select multiple.

 

(Defun C:HH ()
 (command "-HATCH" "S")
 (while (> (getvar 'cmdactive) 0)
   (command pause)
 )
)

or 

(Defun C:HH () (command "-HATCH" "S")) ;enter after selection

 

Edited by mhupp
Link to comment
Share on other sites

Thanks for reply,

this is giving this error.

Command: HH -HATCH
Current hatch pattern:  ANSI31
Specify internal point or [Properties/Select objects/draW boundary/remove Boundaries/Advanced/DRaw order/Origin/ANnotative/hatch COlor/LAyer/Transparency]: S
Select objects: ; error: bad function: "\\"

Select objects: 1 found

Select objects: 1 found, 2 total

Select objects:
Current hatch pattern:  ANSI31
Specify internal point or [Properties/Select objects/draW boundary/remove Boundaries/Advanced/DRaw order/Origin/ANnotative/hatch COlor/LAyer/Transparency]:

and after selecting objects have to hit enter 2 times.

Link to comment
Share on other sites

14 minutes ago, Saqib_theleo said:

yes, but this is not selecting multiple objects.

Odd, tried using crossing window to select groups of rectangles and shift+crossing windows to unselect and it worked fine for me. Fence worked too, how were you trying to select?

Link to comment
Share on other sites

2 minutes ago, tombu said:

Odd, tried using crossing window to select groups of rectangles and shift+crossing windows to unselect and it worked fine for me. Fence worked too, how were you trying to select?

I select closed pline and text one by one.

Link to comment
Share on other sites

6 minutes ago, Saqib_theleo said:

I select closed pline and text one by one.

In your lisp you used "S" to use Select objects mode. You would need to pick "Select objects", enter "S" or set HPPICKMODE (System Variable) to 1 which would make "Select objects" the default to pick objects the way you want.

Then you could multiple select plines and text all at once.

Link to comment
Share on other sites

1 hour ago, tombu said:

In your lisp you used "S" to use Select objects mode. You would need to pick "Select objects", enter "S" or set HPPICKMODE (System Variable) to 1 which would make "Select objects" the default to pick objects the way you want.

Then you could multiple select plines and text all at once.

even changing it to 1 does not select multiple objects. as i select 1st object it draws hatch instantly.

Link to comment
Share on other sites

1 minute ago, Saqib_theleo said:

even changing it to 1 does not select multiple objects. as i select 1st object it draws hatch instantly.

It's supposed to do that with each object you select. Drag your cursor to select multiple objects or enter "F" to select using the Fence option or whatever option you were going to use in the lisp.

Link to comment
Share on other sites

16 hours ago, Saqib_theleo said:

even changing it to 1 does not select multiple objects. as i select 1st object it draws hatch instantly.

Select everything first then use the Hatch command and when you get to the "Select objects" prompt enter "P" to select your previous selection.

Link to comment
Share on other sites

4 hours ago, tombu said:

Select everything first then use the Hatch command and when you get to the "Select objects" prompt enter "P" to select your previous selection.

actually I want a simple Lisp which can be done in minimal click and keys, I want that when I run hatch Lisp it prompts me to select objects in my case it is closed boundary and text (because I want trim hatch on text) and after selecting these 2 objects it creates instantly last used hatch.

If someone can make this Lisp that will be nice.

Thank you.

Link to comment
Share on other sites

Am I missing something here, what is wrong with using a selection set, something like:

 

(defun c:hh ( / )
  (setq MySS (ssget '((-4 . "<OR") (0 . "LWPOLYLINE") (0 . "*TEXT")  (-4 . "OR>"))) )
  (Command "-HATCH" "S" MySS "" "")
)

 

 

You could add to this looping through the selection set to remove any polyline that is not a closed polyline (internet search gave me this snippet which could be used for that https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/check-to-see-if-polyline-is-closed/td-p/859164 )

 

 

 

(and just to note a 'simple Lisp' is often the most complex, which makes it simple for the user, can add in checks that a polyline is closed.... the LISP gets better but not so simple)

Edited by Steven P
  • Like 3
Link to comment
Share on other sites

38 minutes ago, Steven P said:

Am I missing something here, what is wrong with using a selection set, something like:

 

(defun c:hh ( / )
  (setq MySS (ssget '((-4 . "<OR") (0 . "LWPOLYLINE") (0 . "*TEXT")  (-4 . "OR>"))) )
  (Command "-HATCH" "S" MySS "" "")
)

 

 

You could add to this looping through the selection set to remove any polyline that is not a closed polyline (internet search gave me this snippet which could be used for that https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/check-to-see-if-polyline-is-closed/td-p/859164 )

 

 

 

(and just to note a 'simple Lisp' is often the most complex, which makes it simple for the user, can add in checks that a polyline is closed.... the LISP gets better but not so simple)

Hi @Steven P,

Yes this is exactly what I need, works great. It is Selection set which was missing but you made it in to code, so nice.  Right now checking closed polyline is not issue but may be later it will be required.

and yes you are right a "Simple Lisp" can be more complex in these cases I can understand.

Thank you for your help.

  • Like 1
Link to comment
Share on other sites

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