Land F/X
  • Portal
  • Products
    • Design F/X
    • Planting F/X
    • Irrigation F/X
    • F/X CAD
    • Plugin for Revit®
    • Plugin for SketchUp®
    • Lighting
    • Plugin for Rhino®
    • Manufacturer Connection
    • Academic
  • Support
  • Videos
  • Who We Are
  • Trial
  • Purchase
Land F/X
  • Portal
    • Dashboard
    • Account
    • Licenses
    • Data
    • Support
  • Products
    • Design F/X
      • Product
      • Features
      • Trial
      • Purchase
    • Planting F/X
      • Product
      • Features
      • Trial
      • Purchase
    • Irrigation F/X
      • Product
      • Features
      • Trial
      • Purchase
    • F/X CAD
    • Plugin for Revit®
    • Plugin for SketchUp®
    • Plugin for Rhino®
    • Site & Hardscape
    • Lighting
    • Manufacturer Connection
    • Academic
    • Purchase
  • Support
    • Knowledge Base
    • Documentation
    • Submit Ticket
    • Updates
    • Forum
    • Install
    • Remote Assistance
  • Videos
    • Power Tips
    • Webinars
  • Who We Are
    • Contact Us
    • Careers
    • Gallery
    • News
  1. Videos

Intermediate AutoLISP

{"3":{"id":3,"title":"Video Length","name":"video-length","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"Video Length","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"1:07:09","rawvalue":"1:07:09"},"7":{"id":7,"title":"Presented By","name":"presented-by","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"Presented By","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"Jeremiah Farmer","rawvalue":"Jeremiah Farmer"},"11":{"id":11,"title":"vimeo-id","name":"vimeo-id","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"vimeo-id","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"","rawvalue":""},"23":{"id":23,"title":"registration-link","name":"registration-link","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"registration-link","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"","rawvalue":""},"24":{"id":24,"title":"webinar-date","name":"webinar-date","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"webinar-date","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"","rawvalue":""},"37":{"id":37,"title":"Registration","name":"registration","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"Registration","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"","rawvalue":""},"43":{"id":43,"title":"App Video Link","name":"app-video-link","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"App Video Link","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"https:\/\/player.vimeo.com\/external\/280985149.m3u8?s=50f73908d53edfd229d0f9e2236d1b110638bb14&oauth2_token_id=1264298558","rawvalue":"https:\/\/player.vimeo.com\/external\/280985149.m3u8?s=50f73908d53edfd229d0f9e2236d1b110638bb14&oauth2_token_id=1264298558"},"44":{"id":44,"title":"Webinar Vimeo ID","name":"webinar-vimeo-id","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"Webinar Vimeo ID","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"280985149","rawvalue":"280985149"},"46":{"id":46,"title":"ManualDate","name":"manualdate","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"ManualDate","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"","rawvalue":""},"49":{"id":49,"title":"Manufacturer Video Type","name":"manufacturer-video-type","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"Manufacturer Video Type","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"","rawvalue":""},"50":{"id":50,"title":"Manufacturer Video Company","name":"manufacturer-video-company","checked_out":null,"checked_out_time":null,"note":"","state":1,"access":1,"created_time":"2023-12-15 00:00:00","created_user_id":48,"ordering":0,"language":"*","fieldparams":{"filter":"","maxlength":""},"params":{"hint":"","class":"","label_class":"","show_on":"","showon":"","render_class":"","value_render_class":"","showlabel":"1","label_render_class":"","display":"2","prefix":"","suffix":"","layout":"","display_readonly":"2"},"type":"text","default_value":"","context":"com_content.article","group_id":2,"label":"Manufacturer Video Company","description":"","required":0,"only_use_in_subform":0,"language_title":null,"language_image":null,"editor":null,"access_level":"Public","author_name":"Forrestt Williams","group_title":"videos","group_access":1,"group_state":1,"group_note":"","value":"","rawvalue":""}}

July 20, 2018

Presented by: Jeremiah Farmer

Length: 1:07:09

In this follow-up presentation, we’ll apply the principles covered in our AutoLISP Basics webinar to create another usable tool. This time, we’ll create a basic loop that processes all entities in the drawing, while discussing best practices in doing so. We’ll also show how to integrate your custom AutoLISP tools into the ribbon, and how best to organize your source files.

 

 

Webinar attachments:

  • AutoLISP Intermediate files

 

Webinar Contents:

Note: The following catalog of content covered in this webinar is time stamped to allow you to follow along or skip to sections of the video that are relevant to your questions. You can also search for content on this page using the FIND command in your browser (CTRL + F in Windows, Command + F in Mac OS.)

  • Intro/TOC
  • Recap AutoCAD Basics Webinar
  • Lists
  • Selection Sets
  • Ribbon Integration
  • Make a Function That Processes All Entities in the Drawing

 

0:00 – 3:44: Intro/TOC

3:45 – 7:26: Recap AutoCAD Basics Webinar

AutoLISP is a language of mathematics, encapsulated in parentheses. So:

2 + 2 becomes (+ 2 2)

 

Which means you can do: (+2  2 9 7) and assign variables: (set1 Radius (+ 2 2 9 7))

 

Recap data types (4:48)

  • Boolean: t / nil
  • Integer: 0, 1, 2, 3, -65536, 1073741824
  • Real: 3.141592653589793
  • String: “Hi, Mom!”
  • Lists: (101.222 319.045 0.0)
  • Entity name: <Entity name: 2094125b120>
  • Selection Sets: <Selection set: b5> (A selection set is a collection of entity names.)

 

Recap Lists (6:04)

  • Basic: (1 2 3 4)
  • Very common, a Point: (101.222 319.045 0.0)
  • Lists within lists (within lists (within lists)): ( (0 . 10.0) (1 . 4) (2 . “Hi, Mom!”) (3 . 75.44139) )
  • Entity access: ( (0 . “LINE”) (67 . 0) (8 . “0”) (10 250.831 43.694 0.0) (11 271.714 55.7062 0.0)

7:27 – 17:16: Lists

List construction (7:27)

How lists are created (7:27):

Take any number of arguments and spit out an actual list:

  • (list 1 2 3 4)
    • (1 2 3 4)

 

Appending lists (7:47):

  • (append (list 1 2 3 4) (list 5) )
  • (1 2 3 4 5)

 

 

  • (setq MyList (list 1 2 3 4))
    • (1 2 3 4)
  • (setq MyList (append MyList (list 5) ) )
    • (1 2 3 4 5)

 

More list construction (10:06)

  • (cons “distance” 3.5)
    • (“distance” 3.5)

 

  • (list (cons “distance” . 3.5) (cons “entity” E1) (cons “insertion” P1) )
    • ( (“distance” . 3.5) (“entity” . E1) (“insertion” . P1) )
    • (assoc “distance” MyList)
      • (“distance” . 3.5)

 

Control list (13:27)

Goal: Create a list of entities with their distance from a given point

  • One option: Have a list of entities and sort it by their distance. (Problem: This would require constant recalculation of the distance.)
  • Another option: Add to each entity info its distance from point (Problem: The entity definition will be illegal and will generate an error.)
  • Yet another option: Have two lists: one of entities and one of distances (also not a great idea)
  • Consider being able to work with X closest
    • Might want to modify the entity, or display the distance.

Possible result:

 

(

    (<distance> (<entity 1>) )

    ( <distance> (<entity 2>) )

)

17:17 – 18:49: Selection Sets

  • (ssget “X”) – where “X” is everything in the entire DWG
    • Returns a selection set of all entities in the drawing
  • (ssname (ssget “X”) 0)
    • Returns the entity name of first entity in the drawing

18:50 – 21:00: Ribbon Integration

All AutoLISP customization should be organized in the following way:

  • Custom CUIX
  • MNL file of same name, loading your LSP file
  • Menu folder (in Support File Search Path)
    • myOffice.CUIX
    • myOffice.MNL
    • myOffice.LSP
    • Images folder
      • toolA_16.png
      • toolA_32.png

21:01 – end: Make a Function That Processes All Entities in the Drawing

The menu folder from the AutoCAD Support File Search Path (as described above) (21:08)

 

Contents of the MNL file (22:25):

If the desired LISP file is in the Support File Search Path, it will load. If not, the user will be alerted.

 

The ribbon button for the tool we made in the AutoLISP Basics webinar (23:15)

 

Opening the CUI interface and creating a CUI entry for the tool and adding it to a ribbon panel (23:38)

 

Creating a macro and adding images for the tool button in the CUI (24:50)

 

Reloading the code and testing the tool (26:30)

 

Select a Block and Find the Closest (26:56)

Outlining (commenting) and coding the functions that will be built into the tool we’re creating (27:00)

 

Select an entity (29:08)

The importance of specifying the insertion point of the block rather than any point clicked on the block (30:20)

 

Get the entity info (30:50)

Saving, reloading, and testing (Do this often!) (31:30)

 

Make sure it’s a block (32:15)

 

Grab the block’s insertion point (33:02)

 

Grab the block’s name (33:53)

 

Get all of that block (34:04)

The importance of keeping variable names consistent (34:28)

 

The importance of always adding a trailing comment (35:50)

 

Process those blocks (40:00)

 

Calculate distance to the start point (42:33)

Putting in an access panel (44:00)

 

The framework shown at 50:55 should be a cornerstone of your AutoLISP programming.

 

Sort the control list (51:30)

Grabbing the necessary code from the Autodesk Knowledge Network (51:40)

 

Do something with the list (55:18)

  • Draw a line to the X closest (55:40)

 

The importance of naming variables carefully (1:02:42)

 

The importance of including C: at the beginning of commands and including an alert on each command (1:04:38)

Contact

  • Land F/X
  • PMB 351
    3940 Broad St. STE 7
    San Luis Obispo, CA 93401
  • +1 805-541-1003
Email Logo Facebook Logo Instagram Logo LinkedIn Logo
Land F/X Logo

Our software tailors AutoCAD®, Revit®, SketchUp®, and Rhino® to the needs of landscape architects, irrigation designers, and other professionals. We automate your most tedious tasks and ensure accuracy, giving you more time to design.

  • Portal
  • Products
  • Support
  • Videos
  • Who We Are