Jump to content

Recommended Posts

Posted

I am trying to write a LISP code snippet which will draw a simple elevation symbol. That is a circle with some cross-hair lines slightly longer than the diameter and a solid hatch pattern in the upper right and lower left quadrant formed by the cross-hairs.

 

I have tried it like this and it works until I get to the hatch:

 


(setq ip (getpoint "\nEnter Center Point: "))
 (command "._circle" ip 3)
 (command "._line" (polar ip (dtr 180.0) 5.0) "@10<0.0" "")
 (command "._line" (polar ip (dtr 90.0) 5.0) "@10<270.0" "")
 (setq pt5 (polar ip (dtr 45.0) 1.0))
 (setq pt6 (polar ip (dtr 225.0) 1.0))
 (command "._bhatch" "P" "SOLID" "k" "" pt5 pt6)

 

 

NOTE: (dtr) is a simple subroutine which converts degrees to radians and is not shown for brevity.

 

When I do some searches on this I find similar questions being answered but nothing exactly matching what I want. And most of those articles describe how to do this using entmake, not the command line and ._bhatch.

 

I have seen an entmake routine which does this but I do not understand or follow the (cons 10 . 0 xxx) stuff that's going on. And it seems to take 20 lines of entmake to do what the bhatch command line does in one line, yet everyone says the entmake process is faster and cleaner.

 

A little clarification would be appreciated. Thanks.

Posted

Try it this way ..... :)

 

(defun c:TesT (/ ip p1 p2 p3)
 ;;; Tharwat 04. Jan. 2012 ;;;
(if (setq ip (getpoint "\nEnter Center Point: "))
 (progn
   (entmake
     (list '(0 . "CIRCLE") (cons 10 (trans ip 0 1)) '(40 . 3.))
   )
   (entmake (list '(0 . "LINE")
                  (cons 10 (setq p1 (polar ip 0. 5.0)))
                  (cons 11 (polar p1 pi 10.))
            )
   )
   (entmake (list '(0 . "LINE")
                  (cons 10 (setq p2 (polar ip (/ pi 2.) 5.0)))
                  (cons 11 (polar p2 (+ pi (/ pi 2.)) 10.))
            )
   )
   (setq p3 (polar ip (/ pi 4.) 1.))
   (repeat 2
     (command "_.-hatch" "_p" "Solid" p3 "")
     (setq p3 (polar ip (+ pi (/ pi 4.)) 1.))
   )
 )
 (princ)
)
  (princ)
)

Posted

If you're going down the entmake path when creating mulitple objects might as well use Blocks.

otherwise entmake a block object

Posted

Thanks, and as before I am trying to understand the con part of this. As I read the manuals, "con" is contructing a list. So the first list you construct is something like (0 . "CIRCLE"..._ ok I give up. It's hard to follow what's going on here. Where can I find out what all the numbers and . stuff mean. When I search for "autolisp"+"con" I end up with all kinds of examples but so far I can't find out what all the cons 10's and cons 11's mean.

Posted

Reading this now....I have noticed something. Whenever I open the VLISP editor in AutoCAD it opens up the last file I was working on. This could be useful but most of the time it's not. Is there a way to have the editor open up with a clean, empty screen instead of defaulting to the last session?

Posted
Is there a way to have the editor open up with a clean, empty screen instead of defaulting to the last session?

 

Sadly no :D

Posted

Cheese and Crackers.....

 

....just when I was starting to figure this stuff out, I know have to learn that "Radius" or "r" is not spelled that way with entmake. It's spelled "40". Just to be silly I guess.

 

From one of my favorite comedians...Gallegher...

"people I have my questions...like why do you park on a driveway and drive on a parkway....and what is a "peace keeper" atomic missle anyway?

Posted

Bill,

 

I recommend using entmake[x] for the creation of your Lines and Circle, however, IMO, the complexity of creating a Hatch Entity using entmake[x] outweighs the benefits of using the entmake[x] function (unless so required, for example on a Mac); I would suggest using the AddHatch method of a VLA Block Object, or, if you don't want to delve into VL, stick with the command call. I'm not saying you can't create a Hatch entity with entmake[x], but its certainly not straighforward.

 

Read this thread:

http://www.cadtutor.net/forum/showthread.php?63086-Entmake-of-a-Hatch

 

Specifically, my code example here:

 

http://www.cadtutor.net/forum/showthread.php?63086-Entmake-of-a-Hatch&p=430479&viewfull=1#post430479

 

This demonstrates how to entmake a hatch if you wanted to follow that route:

http://www.theswamp.org/index.php?topic=4814.msg194181#msg194181

 

 

 

Lee

Posted

I agree with Lee use entmake, good programing would be to have a defun that is a "entmake" (myline p1 p2) also have other common entities Circle arc etc (mycircle p1 ang1 ang2 rad)

 

Put these entmake defuns into your startup/autoload lsp

 

if you look at higher level programming examples .net C## they always have a entmake type of function. VL ?

 

eg

 

Dim startPoint(0 To 2) As Double, endPoint(0 To 2) As Double
Dim LineObj as AcadLinestartPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
endPoint(0) = 30: endPoint(1) = 20: endPoint(2) = 0
Set LineObj = ThisDrawing.ModelSpace.Addline (startPoint,endPoint)

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