Author Topic: LISP Learning Resources - AutoCAD  (Read 2981 times)

0 Members and 1 Guest are viewing this topic.

e_luvins

  • Guest
LISP Learning Resources - AutoCAD
« on: July 28, 2015, 12:11:59 PM »
I'm new to programming and I'm interested in learning how to create LISP routines for AutoCAD.  I understand how to create and use scripts along with very simple lisp routines, but I want to know more.  My main goal is to automate common tasks within our firm (force standardization) to help guide users.  Currently, I'm interested in understanding and learning how to automate the following process:

1. QSELECT any block references with a Scale X=1
2. Explode
3. QSELECT any block references with a Scale X≠1
4. Change Scale X=1

Any direction to beginner resources is greatly appreciated!

Thanks,
Eric Vallejo, LSI
Missman, Inc.
ericv@missman.com

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Re: LISP Learning Resources - AutoCAD
« Reply #1 on: July 28, 2015, 12:27:13 PM »
Welcome to theSwamp. You're in the right place for questions (theSwamp is an amazing resource of programmers).

May I suggest you start off by creating a post for a specific question you are having in specific areas (post the problem, and any code you have up to that point). Then get ready to sift through many good examples and offers to help.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

77077

  • Guest
Re: LISP Learning Resources - AutoCAD
« Reply #2 on: July 28, 2015, 01:12:01 PM »
e_luvins
Welcome to theSwamp.

1-2
Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssget ":S" '((0 . "INSERT") (41 . 1))))
  2. (command "_.explode"ss "")
  3.  

3-4
Code - Auto/Visual Lisp: [Select]
  1. (setq ss (ssget ":S" '((0 . "INSERT") (-4 . "/=")(41 . 1))))
  2. (setq dxf (entget (ssname ss 0)))
  3. (setq dxf (subst (cons 41 1) (assoc 41 dxf) dxf))
  4. (entmod dxf)
  5.  
« Last Edit: July 28, 2015, 10:39:44 PM by ANJALI »

77077

  • Guest
Re: LISP Learning Resources - AutoCAD
« Reply #3 on: July 28, 2015, 09:39:34 PM »
Hi e_luvins ,can you understand ?

e_luvins

  • Guest
Re: LISP Learning Resources - AutoCAD
« Reply #4 on: July 29, 2015, 06:47:36 PM »
I will give the code a shot, though I don't understand it.....hence, my initial request for direction.  Thanks for putting it together; I will let you know the result and perhaps "learn a lesson".

Thanks,
Eric Vallejo, LSI
Missman, Inc.
ericv@missman.com

ronjonp

  • Needs a day job
  • Posts: 7527
Re: LISP Learning Resources - AutoCAD
« Reply #5 on: July 30, 2015, 10:40:52 AM »
I will give the code a shot, though I don't understand it.....hence, my initial request for direction.  Thanks for putting it together; I will let you know the result and perhaps "learn a lesson".

Thanks,
Eric Vallejo, LSI
Missman, Inc.
ericv@missman.com
Note that each one of the functions in blue is a hyperlink to a description .. you've got some reading to do :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Peter2

  • Swamp Rat
  • Posts: 650
Re: LISP Learning Resources - AutoCAD
« Reply #6 on: July 30, 2015, 02:11:12 PM »
...and I'm interested in learning how to create LISP routines for AutoCAD...
Of course there are many tutorials in the web - here you find a list of some of them:
http://lee-mac.com/tutorials.html
Peter

AutoCAD Map 3D 2023 German (so some technical terms will be badly retranslated to English)
BricsCAD V23

JohnK

  • Administrator
  • Seagull
  • Posts: 10625
Re: LISP Learning Resources - AutoCAD
« Reply #7 on: July 30, 2015, 03:45:02 PM »
...and I'm interested in learning how to create LISP routines for AutoCAD...
Of course there are many tutorials in the web - here you find a list of some of them:
http://lee-mac.com/tutorials.html

Of course you will find many *more* tutorial here (pick a thread and start reading).
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

BIGAL

  • Swamp Rat
  • Posts: 1409
  • 40 + years of using Autocad
Re: LISP Learning Resources - AutoCAD
« Reply #8 on: August 08, 2015, 09:58:12 PM »
A bit more detail

Code: [Select]
(setq ss (ssget ":S" '((0 . "INSERT") (-4 . "/=")(41 . 1)))) ; a selection set of blocks INSERT with a not equal to dxf item 41 is 1
(setq dxf (entget (ssname ss 0))) ; get the 1st value of the selection set starts at 0 in this case ssget has only one 
(setq dxf (subst (cons 41 1) (assoc 41 dxf) dxf)) ; swap the value of dxf code 41 to 1
(entmod dxf) ; update the block
A man who never made a mistake never made anything

danglar

  • Newt
  • Posts: 161
  • Read My Li(s)(p)
Re: LISP Learning Resources - AutoCAD
« Reply #9 on: August 09, 2015, 08:44:26 AM »
Here you find a bunch of PDF AutoLisp Learning books:

https://lispbox.wordpress.com/books/