Transcript
Page 1: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Customizing

Crash Course

Robert Green www.CAD-Manager.com

Page 2: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

The Fundamentals

AutoLISP

For task automation

CUI

For desktop customization

Page 3: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

The CUI command …

• Where everything

is located

• What the

components do

• What the four

areas of the CUI

command allow

you to do

Page 4: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Workspaces …

• What the user

sees/works with

• How they judge

your CUI files

• The flexible UI part

of the CUI

Page 5: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

AutoLISP

• ..

Page 6: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Custom Workspaces …

• Let’s try it out!

• Backup your CUI

before you start

• Build the Workspace

by toggling on/off the

various components.

• Have fun!

Page 7: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Key files and why they matter

• LSP

• Load in order

• What to mess with

• What not to!

Page 8: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

All those wacky file names …

• ACAD20XX.LSP (XX is version)

• ACAD.LSP

• ACAD20XXDOC.LSP (XX is version)

• ACADDOC.LSP

• MENUNAME.MNL

• Help …

Page 9: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

What do they do …

• They load on startup of AutoCAD

• They load in a certain order (listed on previous

slide)

• Some have code in them and some don’t

(ACADDOC.LSP and ACAD.LSP don’t as an

example)

• They reside in the SUPPORT folder …

Page 10: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

ACADDOC.LSP approach …

• Use ACADDOC.LSP to get started

• You create your own ACADDOC.LSP so you

can’t really mess it up

• It loads with every new drawing

• Put in in the SUPPORT folder and start hacking

away

• If you mess up too bad, just delete!

Page 11: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Syntax Basics

• Lists and Arguments

• Rules of AutoLISP

• Variables

• Functions

• Accessing the

command line

• Special characters

• User input

Page 12: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Lists and Arguments

• (+ 20 30)

o Here the + is a FUNCTION and the two numbers

are ARGUMENTS

• (command “line” “0,0” “1,1” “”)

o Here COMMAND is the function, all others are

ARGUMENTS

Page 13: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

The Command Line

• How would you work normally?

• Draw a line between two user points

o Type in LINE to start the line command

o Click POINT for first point location

o Click POINT for second point location

o Type in ENTER to halt the command

• In AutoLISP: (command “line” pause pause “”)

• PAUSE instruction waits for the user

• The “” is equal to hitting the ENTER key …

Page 14: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Some Rules

“For every ( there is an equal and opposite )” – Newton

Like this: (setq A 3.0)

Not like this: (setq A 3.0)) or (setq A 3.0

Same goes for quote marks!

Like this: (setq name “Robert Green”)

Not like this: (setq name “Robert Green)

(setq name Robert Green”)

When formatting numbers always avoid “invalid dotted pairs”

Like this: (setq A 0.5)

Not like this: (setq A .5)

Page 15: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

What’s Going On Here?

• (command “viewres” “y” “5000”)

• (command “-color” “BYLAYER”)

• (command “-linetype” “set” “BYLAYER” “”)

• (command “menu” “menuname.mnc”)

• (command “viewres” “y” pause)

• That’s not so bad …intuitive actually …

Page 16: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

User functions

• Speed for the user

• Lower support for you

• A win-win scenario

• Let’s put everything

we’ve learned into action

to build some functions.

Page 17: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

User Function Examples

(defun C:ZA ()

(command “.zoom” “a”)

(princ)

)

Page 18: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

User Function Examples

(defun C:VR ()

(command “viewres” “y” “5000”)

)

(defun C:BL ()

(command “-color” “BYLAYER”)

(command “-linetype” “set” “BYLAYER” “”)

(princ)

)

Page 19: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Fillet Zero Function

Fillet Zero

(defun c:fz ()

(setvar “filletrad” 0.0)

(command “.fillet” pause pause)

(princ)

)

Page 20: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Improved Fillet Zero

(defun c:fz ()

(setq old_filletrad (getvar “filletrad”))

(setvar “filletrad” 0.0)

(command “.fillet” pause pause)

(setvar “filletrad” old_filletrad)

(princ)

)

Page 21: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Auto Purge Function

Auto Purge

(defun c:atp ()

(command “-purge” “a” “*” “n” “.qsave”)

(princ)

)

Page 22: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

More Bits and Bytes …

• Undefine

• Dot form

• Redefine

• Alerts

• CMDECHO

Page 23: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Undefining …

• (command “.undefine” “LINE”)

• (command “.undefine” “TORUS”)

• Don’t want them messing with a command? Just

undefine it …

Now you can SUBTRACT from the AutoCAD Command set in your ACADDOC.LSP file.

Page 24: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

The DOT form …

• Invoke commands like this: .LINE

• Note the dot “.” character?

• This allows you to invoke a command whether it has

been undefined or not!

• This is our little secret right ...

Page 25: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Redefining …

• (command “.redefine” “LINE”)

• (command “.redefine” “TORUS”)

• Want to be sure that a command is active?

• Just redefine it …

Now you can UNSUBTRACT from the AutoCAD Command set with ease.

Page 26: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Undefining revisted …

• What if your users find out about REDEFINE and start

REDEFINING your UNDEFINES?

• Just undefine the redefine like this:

• (command “.undefine” “REDEFINE”)

• That’ll show ‘em …

Page 27: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Redefining …

• You can undefine a command and redefine it like this:

(command “.undefine” “TORUS”)

(defun C:TORUS ()

(alert “Don’t use that command!”)

(princ)

)

Now you do whatever you want!

Page 28: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Alerting the user …

• You can send a message to the user like this:

(alert “Message goes here”)

Page 29: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

What Does This Do?

(command “.undefine” “QSAVE”)

(defun c:qsave ()

(command “-purge” “b” “*” “n”)

(command “.qsave”)

(princ)

)

Page 30: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Command echo (CMDECHO)

Run in STEALTH mode like this:

(defun C:BL ()

(setvar “cmdecho” 0)

(command “-color” “BYLAYER”)

(command “-linetype” “set” “BYLAYER” “”)

(setvar “cmdecho” 1)

(princ)

)

Page 31: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

The CUI command revisited …

• Create some

commands

• Add some toolbars

• Preview the results

• Workspaces react

accordingly!

Page 32: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Macro cheat sheet

• Using your AutoCAD knowledge to write

some cool functionality into your CUI files

• What does this macro do?

Page 33: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

The transfer tab …

• Transferring elements

between CUI files

• Like a “Vulcan mind

meld” for CUI’s

Page 34: Synergis University 2014-Customizing Crash Course

FROM THE TRAILHEAD TO YOUR CAREER SUMMT.

Customizing

Crash Course

Robert Green www.CAD-Manager.com

Course files: