Author Topic: Whats a good start for Visual Lisp?  (Read 7015 times)

0 Members and 1 Guest are viewing this topic.

CECE_CAD

  • Guest
Whats a good start for Visual Lisp?
« on: September 13, 2006, 05:46:28 PM »
I was told that this was the place to come to learn. I have been using CAD over a few years, for the past year I have slowly been introducing myself into the lisp world. I see the potential for growth and want to learn. What would someone suggest for starters?

Greg B

  • Seagull
  • Posts: 12417
  • Tell me a Joke!
Re: Whats a good start for Visual Lisp?
« Reply #1 on: September 13, 2006, 05:49:13 PM »
Figure out a routine you regularly do when working and can be automated.

Explain what you are trying to achieve with the program you want to create and learn lisp as you develop the program here.

I'd say start out simple...

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Whats a good start for Visual Lisp?
« Reply #2 on: September 13, 2006, 05:52:15 PM »
You could also look at Afralisp.net for some help.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Whats a good start for Visual Lisp?
« Reply #3 on: September 13, 2006, 05:58:11 PM »
<snip> I see the potential for growth and want to learn. What would someone suggest for starters?

Ask a ``question'' pertaining to a ``problem'' and we will beat it to death and give you so many options to choose from you will almost certainly have a conniption fit.

No seriously, do you want to learn VL and applications or did you want to stick with pure AutoLisp and theory or a combo of both? (I highly recommend the 'AutoLisp theory' class, Its buckets of fun.)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

LE

  • Guest
Re: Whats a good start for Visual Lisp?
« Reply #4 on: September 13, 2006, 06:01:35 PM »
Go directly to C#, VB.NET or VBA

CECE_CAD

  • Guest
Re: Whats a good start for Visual Lisp?
« Reply #5 on: September 13, 2006, 06:03:06 PM »
Ok! For example: I was talking with someone on Autodesk chat. He was helping me create a lisp. The lisp is to find a certain block and redefine it, set it to Zero layer then take that same block take it off its current layer and put it to a new layer or create a new layer. I understand what the code is doing but not how to read it. when I try to use the lisp I get (FixLiteBlock ; error: bad argument type: VLA-OBJECT nil)

I work in AutoCAD 2007. I would like to learn this was created. Or try to create it in another way to help me learn it.



Code: [Select]
(vl-load-com)

(defun jb:BlockLayerZero(nameStr newLayer / )
(if (not (tblsearch "layer" newLayer))
(alert (strcat newLayer " does not exist - please creat it first!"))
(progn
(if (tblsearch "block" nameStr)
(progn
(vlax-for x (vla-item (vla-get-blocks jbThisDrawing) nameStr)
(vlax-put-property x 'layer "0")
(vlax-put-property x 'color acByLayer)
(princ "\nLayer changed!"))

(vlax-for blks (vla-get-blocks jbThisDrawing)
(vlax-for blk blks
(if (vlax-property-available-p blk 'name)
(if (=(vla-get-name blk) nameStr)
(vla-put-layer blk newLayer)))))
)
(alert (strcat NameStr " not found!")))))
(princ))

(COMMAND "LAYER" "M" "A-Lite-01")

(defun c:FixLiteBlock( / )
(jb:BlockLayerZero "AL2x4" "A-Lite-01"))


Edit... fixed code tags - Jonesy
« Last Edit: September 14, 2006, 03:08:34 AM by jonesy »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Whats a good start for Visual Lisp?
« Reply #6 on: September 13, 2006, 06:06:03 PM »
OMG,  poor CECE_CAD, getting bombarded at post one.

For Starters , with VL :
The Object Model,
The Help Files,
The Samples installed with AutoCAD,

... and when you hit a wall, ask ..


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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Whats a good start for Visual Lisp?
« Reply #7 on: September 13, 2006, 06:07:23 PM »
Your problem is this line
(vlax-for x (vla-item (vla-get-blocks jbThisDrawing) nameStr)
I'm pretty sure 'jbThisDrawing' is a global variable to hold the active document.  I would just rewrite that line like
Code: [Select]
(vlax-for x (vla-Item (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-Acad-Object))) nameStr)And it should work then.

Edit:  And when you post code, place it in code tags [ code ] to start the code, and [ /code ] to end it (without the spaces).
« Last Edit: September 13, 2006, 06:08:29 PM by T.Willey »
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Birdy

  • Guest
Re: Whats a good start for Visual Lisp?
« Reply #8 on: September 13, 2006, 06:07:35 PM »
Greg's advice is good.  Here's a simple example:
We used to have to switch to a dimension layer everytime we wanted to dimension something, or put the dimensions on their proper layer after the fact.

create a routine that will automatically switch to your proper dim layer every time you invoke a dimension command.
Then take it a step farther... have the routine automatically switch you back to your previous layer when you are done.

Do something similar for your Text annotations.  And hatching... etc.

Again, Greg nailed it.  Start out simple.  Build from there.

Finally, Welcome to the swamp.  Post early, post often.  There's lots of help here.

*Warning - while you were typing3 4n new replies have been posted. You may wish to review your post.* See what I mean!

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Whats a good start for Visual Lisp?
« Reply #9 on: September 13, 2006, 06:07:43 PM »
Well theres your problem right there! Never listen to anyone from AutoDesk chat. *grin* (Okay, never heard of `autodesk chat' but...)

The object missing is the ``thisdrawing'' object.

BUT, do you understand the syntax of the AutoLisp language? For instance: Do you know what a conditiona statment is?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Whats a good start for Visual Lisp?
« Reply #10 on: September 13, 2006, 06:08:22 PM »
Holly cow, you guz got to be fast posters!!
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Birdy

  • Guest
Re: Whats a good start for Visual Lisp?
« Reply #11 on: September 13, 2006, 06:12:27 PM »
<trumped by the gurus>
:)
Don't mind me CECE_CAD.... cept for the welcome.

CECE_CAD

  • Guest
Re: Whats a good start for Visual Lisp?
« Reply #12 on: September 13, 2006, 06:15:05 PM »
<trumped by the gurus>
:)
Don't mind me CECE_CAD.... cept for the welcome.



A BIG THANKS TO ALL!

Birdy

  • Guest
Re: Whats a good start for Visual Lisp?
« Reply #13 on: September 13, 2006, 06:17:25 PM »
<tips hat (for doing nothing)>
These guys are good

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Whats a good start for Visual Lisp?
« Reply #14 on: September 13, 2006, 06:26:13 PM »
<trumped by the gurus>
:)
Don't mind me CECE_CAD.... cept for the welcome.



A BIG THANKS TO ALL!
You're welcome.  If you are willing to learn, people here are willing to teach.  Just come ready to see it from several different views.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.