Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Wanted: Bhatch options/prompts/etc explanation and guide

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
SafetyFish
689 Views, 5 Replies

Wanted: Bhatch options/prompts/etc explanation and guide

Does anyone know of a book or tutorial that completely explains how to write a command line that hatches entities in LISP?

 

I have seen several simple examples that hand the user lines of code that are already written, are at best somewhat explained, and do not offer much advice for how to change the (usually single line) code in order to use the kind of hatching or options I am interested in.

 

I would like to write a series of Autolisp routines that hatch entities as they are created. (mostly polyline squares and circles-- simple stuff)

 

I want these routines to function as quickly as possible. The less clicking, the better. I don't want to use a dialogue box if at all possible.

 

Thanks for looking at my post. Any information you've got would be great!

 

Sydney

 

 

5 REPLIES 5
Message 2 of 6
coopdetat
in reply to: SafetyFish

In the Developer Help Documentation which is accessed by the Help pulldown in VLIDE, look under the DXF Reference /Entities Section/ for HATCH.  The information there tells all that is required to create a hatch entity.  Here is a code snippet of a hatch creation where it has only four corners and no bulges.  In this example the layer assoc list, points, and some other variables have already been defined.  You can examine the entity data in VLIDE for any existing hatch and see the elements required for its definition.

 

(SETQ hatch_ent_lst   (LIST (CONS 0 "HATCH")
                            (CONS 100 "AcDbEntity")
                            (CONS 67 0)
                            (CONS 410 "Model")
                            ent_assoc_8
                            (CONS 100 "AcDbHatch")
                            (CONS 10 (LIST 0.0 0.0 0.0))
                            (CONS 210 (LIST 0.0 0.0 1.0))
                            (CONS 2
                                  (IF skip_dipsolid
                                    "ANSI31"
                                    "ANSI37"
                                  ) ;_ end of IF
                            ) ;_ end of CONS
                            (CONS 70 0)
                            (CONS 71 0)
                            (CONS 91 1)
                            (CONS 92 1)
                            (CONS 93 4)
                            (CONS 72 1)
                            (CONS 10 bdy_pt1) ;top left
                            (CONS 11 bdy_pt2) ;bottom left
                            (CONS 72 1)
                            (CONS 10 bdy_pt2) ;bottom left
                            (CONS 11 bdy_pt3) ;bottom right
                            (CONS 72 1)
                            (CONS 10 bdy_pt3) ;bottom right
                            (CONS 11 bdy_pt4) ;top right
                            (CONS 72 1)
                            (CONS 10 bdy_pt4) ;top right
                            (CONS 11 bdy_pt1) ;top left
                            (CONS 97 0)
                            (CONS 75 0)
                            (CONS 76 1)
                            (CONS 52 0)
                            (CONS 41
                                  (* dimsc
                                     (IF skip_dipsolid
                                       0.6
                                       0.4
                                     ) ;_ end of IF
                                  ) ;_ end of *
                            ) ;_ end of CONS
                            (CONS 77 0)
                            (CONS 78 1)
                            (CONS 53 (* PI 0.25))
                            (CONS 43 0)
                            (CONS 44 0)
                            (CONS 45
                                  (- (* (SIN (/ PI 4))
                                        0.125
                                        dimsc
                                        (IF skip_dipsolid
                                          0.6
                                          0.4
                                        ) ;_ end of IF
                                     ) ;_ end of *
                                  ) ;_ end of -
                            ) ;_ end of CONS
                            (CONS 46
                                  (* (SIN (/ PI 4))
                                     0.125
                                     dimsc
                                     (IF skip_dipsolid
                                       0.6
                                       0.4
                                     ) ;_ end of IF
                                  ) ;_ end of *
                            ) ;_ end of CONS
                            (CONS 79 0)
                            (CONS 98 1)
                            (CONS 10 (LIST 0.0 0.0 0.0))
                      ) ;_ end of LIST
) ;_ end of SETQ
(ENTMAKE hatch_ent_lst)

 

 

---------------------------------------------Signature--------------------------------------------
Civil Design Professional Since 1983 (Intergraph), AutoCAD since 1989

Windows 10 Pro 64-bit Intel﴾R﴿ Core﴾TM﴿ i9-12900KF CPU 3.19GHz; 32 GB DDR4 4266 Dual Channel RAM
nVidia Quadro RTX 4000; AutoCAD Civil 3D 2023.2.1 Update
Message 3 of 6
Kent1Cooper
in reply to: SafetyFish


@SafetyFish wrote:

Does anyone know of a book or tutorial that completely explains how to write a command line that hatches entities in LISP?

.... 

I would like to write a series of Autolisp routines that hatch entities as they are created. (mostly polyline squares and circles-- simple stuff)

.... 


To write any command line operation in Lisp, see the AutoLISP Reference under (command).  All you do is replicate the input to the command as you would enter it at the Command: prompt to do it manually, with a few syntax requirements.

 

To hatch a Circle or closed Polyline or Elipse or Spline that you've just drawn, it can be as simple as this:
 

(command "_.hatch" "yourPattern" yourScale yourAngle "_last" "")

 

Substitute appropriate content for the "your..." parts.  Numerical entries like the yourScale and yourAngle parts can be in double-quotes or not; they and the pattern name can also be fed in from some kind of stored variable.

 

For other options like User-defined patterns, again, just answer the command prompts:
 

(command "_.hatch" "_user" 30 1.25 "_yes" "_last" "")

 

For an explanation of each piece, do it manually and see what the prompts are that they are answering.  The one that might not be entirely clear in that regard is that the double double-quote "" at the end is an Enter to complete the selection of objects to hatch, which also finishes the command.

Kent Cooper, AIA
Message 4 of 6
SafetyFish
in reply to: SafetyFish

Thanks a bunch! That is exactly the information I needed.

Message 5 of 6
Kent1Cooper
in reply to: SafetyFish


@SafetyFish wrote:

Thanks a bunch! That is exactly the information I needed.


If it was my post that you were replying to, you're welcome, and that brings up something people might want to know.

 

I find that if I look at a thread on this website when I'm not yet signed in, see something I'd like to reply to, and pick on the Reply button for that message, causing the Sign In box to come up, after I sign in my Reply ends up being categorized as being in reply to the original message on the thread, not in reply to the message on whose Reply button I picked.

 

I suspect that's what SafetyFish did -- without being signed in, picked on either coopdetat's or my message's Reply button, and was then asked to sign in to post a reply.  So that post is listed as being in reply to their own original post, and not to either coopdetat or me.

 

If you want your reply to correctly identify the author of the message you're replying to, it seems you need to sign in first, and then pick on a Reply button.  [I'd also appreciate it if they would add something that indicates which message (e.g. the Message number) it's in reply to, not just the author.  Often there are multiple messages from the same person, and sometimes it makes a difference which of them is being replied to.]

Kent Cooper, AIA
Message 6 of 6
SafetyFish
in reply to: SafetyFish

Everyone's replies were helpful. I have attached the code I eventually ended up writing. Thanks for all the help.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost