Author Topic: Learning the new Lisp ways  (Read 12924 times)

0 Members and 1 Guest are viewing this topic.

Craig

  • Guest
Learning the new Lisp ways
« on: November 18, 2003, 04:51:32 PM »
Aiight guys, I am about to tackle the task of learning the new VLisp and will be asking bunches of questions. What I want to know to start is where can I find the property values for the line below.
(vlax-get-property doc 'FullName)

'Fullname
'Modelspace
'Color
etc.. Where can I find a list of these values that can be called for?

Remember, this is just the start

daron

  • Guest
Learning the new Lisp ways
« Reply #1 on: November 18, 2003, 04:57:06 PM »
In the help file, there is a reference called "ActiveX and VBA Reference". In there you will find what you are looking for, but you'll need to use (vlax-get-acad-object), which you'll find under v of the Autolisp reference. If you're in the vlide and you inspect (vlax-get-acad-object), you'll get a list popup with all the properties of the acad database, which is what that is. You can double click on properties in the popup and see what's nested. You use (vla-get-activedocument (vlax-get-acad-object)) to access the drawings object model. Hope that helps you start.

Mark

  • Custom Title
  • Seagull
  • Posts: 28753
Learning the new Lisp ways
« Reply #2 on: November 18, 2003, 05:04:22 PM »
check this out.
Code: [Select]

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-dump-object doc)
TheSwamp.org  (serving the CAD community since 2003)

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Learning the new Lisp ways
« Reply #3 on: November 19, 2003, 08:58:52 AM »
Here ya go Craig, Ill give you a compariative study to do also. Study these lisps and they should get you started down the right path in the help files. The first one is easy (You alreay know how to do that. but I have to put it in the post just cause...) The second is the equiliviant of the first. Study each "vl" expression untill you know them like the back of your hand and you will understand better.

(Thats important! Study each "vl" expression and you will have a god start to the Vl-stuff.)

Code: [Select]
(defun c:AMove ()
  (setvar "cmdecho" 0)
  (setq ent (entsel)
        pt1 (getpoint "\nEnter first point: ")
        pt2 (getpoint "\nEnter second point: "))
  (command "_.move" ent "" pt1 pt2)
  (setvar "cmdecho" 1)
(princ)
)

(defun c:vl-Move ()
  (vl-load-com)
  (setq ent (entsel)
        entname (car ent)
        entobj (vlax-ename->vla-object entname)
        pt1 (getpoint "\nEnter first point: ")
        pt1obj (vlax-3d-point pt1)
        pt2 (getpoint "\nEnter second point: ")
        pt2obj (vlax-3d-point pt2))
  (vla-move entobj pt1obj pt2obj)
 (vlax-release-object entobj)
(princ)
)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Learning the new Lisp ways
« Reply #4 on: November 19, 2003, 09:41:29 AM »
.. or it could be wtitten like this, with no variables :--
Code: [Select]

(vl-load-com)



(defun c:xxx-Move ()
  (vla-move (vlax-ename->vla-object (car (entsel)))
            (vlax-3d-point (getpoint "\nEnter first point: "))
            (vlax-3d-point (getpoint "\nEnter second point: "))
  )
  (princ)
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Learning the new Lisp ways
« Reply #5 on: November 19, 2003, 10:04:36 AM »
I know that, You know that, and he knows that. Thats fine and dandy, but that isnt the point. I used "Proper" format for a reason.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Craig

  • Guest
Learning the new Lisp ways
« Reply #6 on: November 19, 2003, 10:15:06 AM »
Hey, thanks John. This will really help me get started. When I'm typing this new program out I still out of habit put in autolisp code that I've been doing for years. Gotta get out of that habit.

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Learning the new Lisp ways
« Reply #7 on: November 19, 2003, 10:32:52 AM »
No problem. Yeah, that will go away when you change your mode of thinking a bit towards the "Object/Properties" instead of "Ent/Associations".
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Learning the new Lisp ways
« Reply #8 on: November 19, 2003, 10:41:40 AM »
Oh, side note: I found it hard to go back; A little while ago, i was on this kick of creating functions that would do things the "old way". (Watch this craig, Daron and Stig are gonna go at it again. {Daron called Autolisp "old" once and i could almost see stig's eyes open wide in confusion} ...lmao) I was checking to see if there was a circle in a block and see the circ's props with assoc code. That got a bit tricky; I couldnt remeber anything. lol
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

daron

  • Guest
Learning the new Lisp ways
« Reply #9 on: November 19, 2003, 10:51:51 AM »
Nah, I don't think we'll go at it again. I admit defeat. He put me in my place. Reading his site'll do that. As far as it being old, it is. Isn't lisp the second oldest language? I don't even know what the oldest language is. From the tests we've driven on this site, my eyes have been opened to considering what will work quickest when I have to code for speed. Some "old" functions are still superior to the new activeX. Even VBA seems to be slower than lisp. Heh!

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Learning the new Lisp ways
« Reply #10 on: November 19, 2003, 10:57:11 AM »
Bawahahaha!

I think it is fortran.

Daron, why is ActiveX is slower then lisp? (why do you think it is the way it is.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Learning the new Lisp ways
« Reply #11 on: November 19, 2003, 10:58:16 AM »
:shock:

I know there ain't line numbers in BASIC anymore .. BUT!

daron

  • Guest
Learning the new Lisp ways
« Reply #12 on: November 19, 2003, 10:58:31 AM »
That's what I was thinking, but 'm not sure. Is fortran a dead language?

JohnK

  • Administrator
  • Seagull
  • Posts: 10603
Learning the new Lisp ways
« Reply #13 on: November 19, 2003, 11:00:06 AM »
I have a fortran compiler. Its still used.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
Learning the new Lisp ways
« Reply #14 on: November 19, 2003, 11:00:15 AM »
There are many languages older than LISP - just think of how Ada got it's name! LISP is merely the second oldest language still in use.