Jump to content

Recommended Posts

Posted

I've made a circle and I would like to know how to get these 4 points.

2h0XA

I'm almost sure that it's going to use angle stuff, for 90º, 180º, 270º and 360º.

But I have no idea how to make this code work haha D:

Can you guys help me?

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • fabriciorby

    9

  • Tharwat

    8

  • Lee Mac

    4

  • Stefan BMR

    1

Top Posters In This Topic

Posted

Try this ...

 

(defun c:Test (/ s e d lst)
 (if (and (setq s (car (entsel "\n Select circle :")))
          (eq (cdr (assoc 0 (setq e (entget s)))) "CIRCLE")
          (setq d (cdr (assoc 40 e)))
     )
   (foreach x (list 0. (* pi 0.5) pi (* pi 1.5))
     (setq lst (cons (polar (cdr (assoc 10 e)) x d) lst))
   )
 )
 lst
)

Posted

Alternatively,

(defun c:cpt ( / cn en rd )
   (if (setq en (ssget "_+.:E:S" '((0 . "CIRCLE"))))
       (progn
           (setq en (entget (ssname en 0))
                 cn (cdr (assoc 10 en))
                 rd (cdr (assoc 40 en))
           )
           (mapcar '(lambda ( x ) (mapcar '+ cn x))
               (list (list rd 0.0) (list 0.0 rd) (list (- rd) 0.0) (list 0.0 (- rd)))
           )
       )
   )
)

Posted

Another . :D

 

(defun c:Test (/ FindQuadrants s e)
 (defun FindQuadrants (e / d l)
   (setq d (cdr (assoc 40 e)))
   (mapcar (function
             (lambda (x)
               (setq l (vl-list* (polar (cdr (assoc 10 e)) x d) l))
             )
           )
           (list 0. (* pi 0.5) pi (* pi 1.5))
   )
   l
 )
 (if (and (setq s (car (entsel "\n Select circle :")))
          (eq (cdr (assoc 0 (setq e (entget s)))) "CIRCLE")
     )
   (FindQuadrants e)
 )
)

Posted

And another

(defun C:QPOINTS ( / e)
 (if
   (setq e (ssget ":E:S" '((0 . "CIRCLE"))))
   ((lambda (p e)
      (mapcar
        (function
          (lambda (x)
            (vlax-curve-getPointAtParam e (* pi x))
            )
          )
        p
        )
      )
     '(0.0 0.5 1.0 1.5)
     (ssname e 0)
     )
   )
 )

Posted (edited)

Thank you guys :D

One day I'm going to learn enough lisp stuff ):

 

Is there a way to make this code prettier?

(setq s (ssget "_+.:E:S" '((-4 . "<OR")(0 . "LWPOLYLINE")(0 . "CIRCLE")(-4 . "OR>"))))
(setq tipo (cdr(assoc 0(entget(ssname s 0)))))
   (if (= "LWPOLYLINE" tipo)
   ................................
   )
   (if (= "CIRCLE" tipo)
   ................................
   )
)

(defun LM:MAssoc ( key lst / item )
   (if (setq item (assoc key lst))
       (cons (cdr item) (LM:MAssoc key (cdr (member item lst))))
   )
)

 

Where do you write your codes?

When did you guys start learning lisp?

 

Sorry, too many questions haha

Edited by fabriciorby
too many questions yet
Posted

This one works as well . :lol:

 

(defun c:TesT (/ s e d i l) (vl-load-com)
 (if (and (setq s (car (entsel "\n Select circle :")))
          (eq (cdr (assoc 0 (setq e (entget s)))) "CIRCLE")
     )
   (progn
     (setq d (/ (* pi (* (cdr (assoc 40 e)) 2.)) 4.) i d )
     (repeat 4 (setq l (vl-list* (vlax-curve-getpointatdist s i) l)
             i (+ i d)
       ))
     ))
 l
)

Posted

Another:

(defun c:cpts ( / cn en pt pl )
   (if (setq en (ssget "_+.:E:S" '((0 . "CIRCLE"))))
       (progn
           (setq en (entget (ssname en 0))
                 cn (cdr (assoc 10 en))
                 pt (list (cdr (assoc 40 en)) 0.0)
           )
           (repeat 4
               (setq pt (list (cadr pt) (- (car pt)))
                     pl (cons (mapcar '+ cn pt) pl)
               )
           )
       )
   )
)

Posted
Is there a way to make this code prettier?

 

I'm guessing you are looking for something like this:

(defun c:myprogram ( / cen enx pnt sel )
   (if (setq sel (ssget "_+.:E:S" '((0 . "LWPOLYLINE,CIRCLE"))))
       (if (= "LWPOLYLINE" (cdr (assoc 0 (setq enx (entget (ssname sel 0))))))
           (while (setq pnt (assoc 10 enx))
               (entmake (list '(0 . "POINT") pnt))
               (setq enx (cdr (member pnt enx)))
           )
           (progn
               (setq cen (cdr (assoc 10 enx))
                     pnt (list (cdr (assoc 40 enx)) 0.0)
               )
               (repeat 4
                   (setq pnt (list (cadr pnt) (- (car pnt))))
                   (entmake (list '(0 . "POINT") (cons 10 (mapcar '+ cen pnt))))
               )
           )
       )
   )
   (princ)
)

 

PS: I'd prefer if you retained my function headers in future ;)

Posted
Where do you write your codes?
One of 2 places:

 

  1. ACad's VLIDE (just type VLIDE at the command prompt). Allows you to run your code directly inside acad together with debugging, you can also inspect other stuff or list all the lisp symbols, also has an Auto-Formatting function to rearrange code by placing new lines and indenting.
  2. Using a programmer's text editor (http://sixrevisions.com/tools/12-excellent-free-text-editors-for-coders/), normal Notepad and the like is a bit useless IMO. I use either Notepad++ or SciTE, but many others have similar capabilities. These usually have more tools for editing code like regex search & replace, folding, line numbering, indication of bracket levels, etc. The editor makes a big difference on figuring out what the code is doing and if you have a typo somewhere, e.g. with a decent editor you never need to count how many closing brackets are needed.

When did you guys start learning lisp?
I think most over here are from all walks of programming. Especially in Lisp you find many who have simply started because they needed something which made a task a bit easier / faster. All the way through to others who have actually been programmers before and now also do AutoLisp. It all depends on how much they want to achieve.

 

Personally, I've started with AutoLisp in the late 80's by fiddling with it for myself. Well, actually my first intro into programming was at school playing about with GWBasic on an old IBM-PC, but I don't really count that since I was only playing about and only for a short while. Later I actually did a CS degree and "learned" to program (in other languages such as Pascal, C++, Java). Ever since then programming is something I simply do because I love to. I make a point of learning a "new" language whenever I can. You pick up new ideas the more you see how other languages go about certain tasks, making you able to do something in a different way in even one of the old languages - not necessarily better though.

 

Though from all the languages I've learned, only lisp has given me so much bang for my buck. The others range from extremely complex to make a similar task, to being too simple to be of as much use. But no others have so much capabilities in such a simplistic arrangement as lisp has. Note here I'm referring to Lisp in the braoder sense - AutoLisp is only a dialect, which has been chopped to pieces omitting huge chunks of what true Lisp actually can do.

Posted

That is interesting, Irneb (:

Thank you for sharing!

You must be a very expert coder haha

 

I've tried VB.NET and Java some time ago. I didn't like coding so I stopped with everything. ):

Nowadays I'm working with AutoCad and I got a lot of curiosity about AutoLisp and everything. Maybe I should try VB again. (:

 

I'm using Notepad++ only, VLisp interface is not as friendly as it's useful.

I'll learn how to use VLisp editor correctly... Is there a way to change the background color and the 'language' color too?

Just like this:

2hvxD

It would be very helpful haha

Posted

I'll learn how to use VLisp editor correctly... Is there a way to change the background color and the 'language' color too?

 

Open the Notepad++ then go to Settings in menu and chose the second option which is Style Configurator and from the first popup list chose

whatever you want to change and there are many more ...

 

Enjoy it . :P

Posted
Open the Notepad++ then go to Settings in menu and chose the second option which is Style Configurator and from the first popup list chose

whatever you want to change and there are many more ...

 

Enjoy it . :P

But how to change it in VLisp Editor D:

edit: I use the Deep Black theme in notepad++ :D

Posted
But how to change it in VLisp Editor D:

I use the Deep Black theme :D

 

I don't think that you can change the background in Vlide .

 

What's wrong with the configuration of the Vlide ? is it not looks good ? :o

Posted
I don't think that you can change the background in Vlide .

 

What's wrong with the configuration of the Vlide ? is it not looks good ? :o

 

Yeah, it doesn't. ):

I tried to change but every time it closes it get back to the same thing, so sad.

edit: White background for coding is not as good as a black one ):

Posted
Yeah, it doesn't. ):

 

Not a problem , you'd get used to it in no time :D.

Posted
Not a problem , you'd get used to it in no time :D.

 

Dammit, white bg :lol:

Posted
I don't think that you can change the background in Vlide.

 

Yes you can, go to Tools > Window Attributes > Configure Current

Posted
Yes you can, go to Tools > Window Attributes > Configure Current

Thank you :D

It's not that beautiful...

2hxlz

But it works hahaha

Any tip to put the line number just like Notepad++ does?

Posted
Yes you can, go to Tools > Window Attributes > Configure Current

 

Unfortunately I can not change the Background because I have the Window Attributes dialog in my First version cad 2009 empty

without any colour , but with the Cad 2013 is available completely , That's really odd .

 

And I did change it in Cad 2013 and pasted the file in Cad 2009 and it is working normally :)

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