Вы находитесь на странице: 1из 10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

Home

Blog

Tw itter

YouTube

Contact

Like

58

Send

AutoLISP / Visual LISP

Home

Softw are

CAD

Contac t

About

Navigate
Home JTB FlexReport SmartPurger AutoCAD Automation Tools SSMPropEditor ACAD_db ACA_db Dw gNotes DW G Columns for Explorer Dw gInfoTip for Explorer V uuc h for AutoCAD X ClipClean TimberTool
www.jtbworld.com/lisp.htm

Free AutoLISP and Visual LISP code snippets for AutoCAD


Please feel free to be inspired, cut&paste or if you have any feedback or questions go here. If you want some customization or anything else that you can come up with that we might help you with you're welcome to contact us. Want to learn LISP for AutoCAD? The Visual LISP Developer's Bible, 2011 Edition

1/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

DimNotes TransTips OffsetInX ref JTB FlexReport LT Catenary HTools HV ACPAC UnitCAD Softw are and freew are CAD AutoCAD AutoCAD 2010 AutoCAD 2011 AutoCAD 2012 AutoCAD 2013 AutoCAD 2014 AutoLISP / V isual LISP Training V ideos and Books Blog Customers Contac t About

acad.lsp Instruction on the usage acaddoc.lsp Instruction on the usage accdist.lsp Accumulate distances to AecExportToAutoCAD.lsp Read and write the settings that AecExportToAutoCAD and the like command uses AECObjectsExplodeOptions.lsp Read and write the settings in the "Explode AEC Objects" dialog box when using command _AecObjExplode AreaM .lsp Calculates the total area of selected objects areaOfObject.lsp Returns the area of selected object AreaText.lsp Select a polyline and where to place the text for the area AttDefToM Text.lsp Convert Attribute definitions to M Text AttDefToText.lsp Convert Attribute definitions to Text axBlock.LSP Generic block and attribute AutoLISP functions axCreateVP.LSP Creation of viewports using AutoLISP axInsert.lsp Example of inserting a block with ActiveX in modelspace backgroundchanger.lsp Change the background color back and forth BlockToXref.lsp Convert Blocks to Xrefs BOM Lengths.lsp Get the accumulated sum length of multiple objects CAO_Link_Templates.lsp Create/delete Link Templates using CAO ChangeNoPlottableLayers.LSP move all entities from layers that are not plottable to layer defpoints dimlinechange.lsp Changes selected line on a dimension to current layer
2/10

Blog Headlines
AutoCAD performanc e issues and V BA Here is a reason why you may not want to use VBA if you have 64-bit version of AutoCAD Change AutoCAD 2014 from
www.jtbworld.com/lisp.htm

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

Netw ork lic ense to Standalone AutoCAD 2014 and its verticals can easily be changed between Network, Standalone and Multiseat Standalone licensing with a small Fix for c rash during startup of an Autodesk 2014 produc t This hotfix Windows crash during license authorization Hotfix by Autodesk can help if you have problem to start any Spot Elevation Hotfix for Autodesk Revit 2013 This hotfix improves product stability when placing Spot Elevations within Section Views in Autodesk Revit 2013. Autodesk Point Lay out released Another acquisition by Autodesk. Autodesk, Inc. has completed the acquisition of technology assets from Colorado-based Get The Point, LLC JTB FlexReport 7.4.3 This new version of JTB FlexReport license report solution adds some new functionality and solves some other issues: Added AutoTrac k and Sam ac quired by Autodesk According to this press release Autodesk Expands Infrastructure Design and Analysis Portfolio With Acquisition of Sam and AutoTrack Software. Autodesks Tinkerc ad export to Minec raft
www.jtbworld.com/lisp.htm

DisplayColorProperties.lsp M iscellaneous commands related to Colors on the Display tab on the Options dialog DisplayProperties.lsp M iscellaneous commands related to the Display tab on the Options dialog DLF.lsp Delete AutoCAD layer filters GetPlotDevices.lsp Generic plot setting functions to get plot styles and plotters available getvpscale.lsp Get Viewport Scale in active viewport or in selected Hatch_M ove.lsp M oves the startpoint/snapbase for selected hatches base points independently HATCHB.LSP Recreates hatch boundary by selecting a hatch HatchBase.lsp Change the hatch base point on one or many hatches historylines.lsp Change the number of command history lines insrot.lsp 2 versions of Insert block with attribute rotated to specified angle JTB_TitleBar.lsp Change the title bar of the AutoCAD application layer-list.LSP Layer list to file layer-lw-list.LSP Layer and lineweight list is created as a drawing layers-erase.LSP Erase all layers that are frozen or off layer-state.LSP List layers according to state layer-toggle-freeze.lsp toggle the freeze state of layer and regens only the objects on the layer LayoutsToDwgs.lsp Creates separate drawings of all layouts lengthOfObject.lsp Returns the length or the perimeter of selected object linetype.LSP Load linetype and check for existence of specified linetype mpt.lsp M idpoint of 2 or 3 points pagesetup.lsp M iscellaneous routines related to Page Setup PersonalM textSymbols.lsp Add personal mtext symbols in the right click menu in the mtext editor pljoinfuzz.lsp Joins lines, arcs and polylines using a fuzz distance PlotDevicesFunctions.lsp M iscellaneous Plot Devices Functions plotdialog.lsp Force Plot dialog by lisp profiles.lsp M iscellaneous profile commands ProjectPaths.lsp Project path functions including export to file Purge-Point.lsp Kills all POINT 5 vent-objects and V50-dictionaries purger.lsp Various purge functions with no command line echo PurgeReconciledLayers.LSP Purge all information about reconciled layers in the drawing
3/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

Autodesk purchased Tinkercad in May 2013 (ref) and with Tinkercad you can now export 3D models via Download for Folders and files c annot be saved w hen Autodesk 360 is not running This error can happen in AutoCAD 2014 and verticals. When you run Save As in an existing drawing, the Autodesk University 2013 w ebsite new s This year AU has a new logo and a new website. The search for Classes on Demand is updated

remicons.lsp Removes the icons Buzzsaw, RedSpark, Point A and FTP in Open dialog box SOpen.lsp Open command that works for all cases independent on SDI supportPaths.lsp Save and loads support paths to a text file TextFunctions.lsp Change all text styles on all objects to named text style TextHeight.lsp Text is resized based on the justification point tsh0.lsp Set all text style's height to 0 txtRot.lsp Rotate selected text objects to specified angle viewportcenter.LSP Get the viewport center coordinates viewsIO.LSP Export and import views VPlayers.lsp Save, load and restore frozen viewport layers from file and match from one viewport to another vp-outline.LSP Creates a polyline in modelspace that has the outline of the selected viewport vpsel.lsp Select all visible objects in selected or active paperspace viewport XrefRename.lsp Rename xref and update path XrefRepath.lsp - Repath xrefs to use relative paths instead of absolute paths. zoome.lsp Zoom extents in all viewports Download acetutil.zip Documentation for the Express acet functions wcmatch AutoCAD AutoLISP function Some free AutoLISP code by M ark Beggs

Subscribe to the blog

AutoLISP / Visual LISP


AutoLISP is based on the LISP programming language. Because AutoCAD has a builtin LISP interpreter, you can enter AutoLISP code at the command prompt or load AutoLISP code from external files. Visual LISP (VLISP) is a software tool designed to expedite AutoLISP program development. AutoLISP and Visual LISP is often used mutually but AutoLISP is only a subset of Visual LISP. Visual LISP was incorporated into AutoCAD 2000 released in M arch 1999, as a replacement for AutoLISP. Visual LISP technology is a tool for code creation in the AutoCAD software application. It is a full-featured, interpretive programming language that you can use to call AutoCAD commands, system variables, and dialog boxes. Visual LISP offers a complete development environment, including Reduced development time using the integrated development environment (IDE), which makes it easier and faster for users and developers alike to
www.jtbworld.com/lisp.htm 4/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

create, debug, and deliver AutoLISP-based applications Access to M icrosoft ActiveX objects and event reactors Source code protection against theft and alteration Operating system file-operation functions LISP function extensions for list processing

Miscellaneous tips and trix for AutoCAD AutoLISP


; AutoLISP function to convert degrees to radians (defun dtr (a) (* pi (/ a 180.0)) ) ; AutoLISP function to convert radians to degrees (defun rtd (r) (* 180.0 (/ r pi)) ) Visual LISP example how to delete all empty layouts (tabs). If the layout has been activated it will contain a viewport object and will not be deleted by this function. In previous version (= nil (ssget "x" (list (cons 410 (vla-get-name layout))))) was used but did not catch layouts where the viewport object has been deleted. vla-getcount will return 0 for non activated layouts and 1 for a layout with no objects.

Ad serv ice by TEAM

www.jtbworld.com/lisp.htm

5/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

( d e f u nc : D e l e t e E m p t y L a y o u t s( /l a y o u t sl a y o u ti ) ( v l l o a d c o m ) ( s e t qi0l a y o u t s( v l a g e t L a y o u t s( v l a g e t a c t i v e d o c u m e n t( v l a x g e t a c a d o b j e c t ) ) ) ) ( i f( >( v l a g e t c o u n tl a y o u t s )2 ) ( v l a x f o rl a y o u tl a y o u t s ( i f( =( v l a g e t M o d e l T y p el a y o u t ): v l a x f a l s e ) ( i f( <( v l a g e t c o u n t( v l a g e t b l o c kl a y o u t ) )2 ) ( p r o g n ( p r i n c( s t r c a t" \ n "( v l a g e t n a m el a y o u t )"d e l e t e d " ) ) ( s e t qi( 1 +i ) ) ( v l a d e l e t el a y o u t ) ) ) ) ) ) ( c o n d ( ( >i1 )( p r i n c( s t r c a t" \ n "( i t o ai )"l a y o u t sd e l e t e d " ) ) ) ( ( =i0 )( p r i n c" \ n N ol a y o u t sd e l e t e d " ) ) ) ( p r i n c ) )

Purge layer filters / delete layer filters in AutoCAD. You get it here at my blog or here.

www.jtbworld.com/lisp.htm

6/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

;T os e tt h eac u s t o ms c a l e ,f i r s ts e tt h eS t a n d a r d S c a l ep r o p e r t yt oa c V p C u s t o m S c a l e , ;t h e nu s et h ep r o p e r t yC u s t o m S c a l et od e f i n et h ec u s t o ms c a l ev a l u e . ;C o d ee x a m p l e st op l a yw i t hf o l l o w

( s e t qa l( v l a g e t A c t i v e L a y o u t( v l a g e t a c t i v e d o c u m e n t( v l a x g e t a c a d o b j e c t ) ) ) ( v l a g e t C u s t o m S c a l ea l ) ( v l a p u t S t a n d a r d S c a l ea la c V p C u s t o m S c a l e ) ( v l a p u t S t a n d a r d S c a l ea la c V p S c a l e T o F i t ) ( v l a p u t S t a n d a r d S c a l ea la c 1 _ 1 0 ) ( s e t qn u m e r a t o r1 ) ( s e t qd e n o m i n a t o r2 5 ) ( v l a s e t C u s t o m S c a l ea ln u m e r a t o rd e n o m i n a t o r ) ( v l a g e t C u s t o m S c a l ea l' n u m e r a t o r' d e n o m i n a t o r ) ( p r i n cn u m e r a t o r ) ( p r i n cd e n o m i n a t o r )

www.jtbworld.com/lisp.htm

7/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

;T h ei sh o wy o uc a nd oaP G Pf i l er e i n i t i a l i z a t i o n( r e l o a d ) a w i n gt e m p l a t ef i l eu s e db yQ N E W ; ; ;( a x : G e t Q n e w P a t h ) ( d e f u na x : G e t Q n e w P a t h( /p r o fk e y ) ( s e t qp r o f( v l a g e t A c t i v e P r o f i l e( v l a g e t p r o f i l e s( v l a g e t p r e f e r e n c e s( v l a x g e t A c a d O b j ( s e t qk e y( s t r c a t" H K E Y _ C U R R E N T _ U S E R \ \ "( v l a x p r o d u c t k e y )" \ \ P r o f i l e s \ \ "p r o f" \ \ G e n e r a l " ) ( v l r e g i s t r y r e a dk e y" Q n e w T e m p l a t e " ) )

; ; ;S e tt h ed r a w i n gt e m p l a t ef i l eu s e db yQ N E W ; ; ;T h i sw r i t e si tt ot h er e g i s t r yb u ti sl a t e rd i s m i s s e da n do v e r w r i t t e nb yA u t o C A D ; ; ;( a x : S e t Q n e w P a t h" M : \ \ C A D \ \ A C A D I S O . D W T " ) ( d e f u na x : S e t Q n e w P a t h( Q n e w P a t h/p r o fk e y ) ( s e t qp r o f( v l a g e t A c t i v e P r o f i l e( v l a g e t p r o f i l e s( v l a g e t p r e f e r e n c e s( v l a x g e t A c a d O b j ( s e t qk e y( s t r c a t" H K E Y _ C U R R E N T _ U S E R \ \ "( v l a x p r o d u c t k e y )" \ \ P r o f i l e s \ \ "p r o f" \ \ G e n e r a l " ) ( v l r e g i s t r y w r i t ek e y" Q n e w T e m p l a t e "Q n e w P a t h ) ) ; ;G e t sc u r r e n tt e m p l a t e ( g e t e n v" Q n e w T e m p l a t e " ) " c : \ \ m yf i l e s \ \ t e m p l a t e s \ \ q n e w . d w t " a n d ; ;S e t sad i f f e r e n tt e m p l a t e ( s e t e n v" Q n e w T e m p l a t e "" c : \ \ m yf i l e s \ \ t e m p l a t e s \ \ q n e w . d w t " )

or another approach because the above one is not working in newer versions of AutoCAD: Using VBA where QnewPath is the Template File Name: ThisDrawing.Application.Preferences.Files.QNewTemplateFile = QnewPath Using LISP: (vla-put-QNewTemplateFile (vla-Get-Files (vla-Get-Preferences (vlax-getacad-object))) QnewPath) T h i si sh o wy o uc a np r e s e tt h eP a t ht y p ei nt h ex r e fa t t a c hd i a l o gb o x ; ; ;S e t st h eX r e fP a t ht y p eu s e di nt h ex r e fa t t a c hd i a l o gb o x ; ; ;A b s o l u t eP a t h :( S e t P a t h T y p e0 ) ; ; ;R e l a t i v eP a t h :( S e t P a t h T y p e1 ) ; ; ;N oP a t h :( S e t P a t h T y p e2 )
www.jtbworld.com/lisp.htm

( d e f u nS e t P a t h T y p e( v )

8/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

( d e f u nS e t P a t h T y p e( v ) ( v l l o a d c o m ) ( v l r e g i s t r y w r i t e ( s t r c a t " H K E Y _ C U R R E N T _ U S E R \ \ " ( v l a x p r o d u c t k e y ) " \ \ P r o f i l e s \ \ " ( v l a g e t a c t i v e p r o f i l e ( v l a g e t p r o f i l e s ( v l a g e t p r e f e r e n c e s( v l a x g e t a c a d o b j e c t ) ) ) ) " \ \ D i a l o g s \ \ X a t t a c h D i a l o g " ) " P a t h T y p e " v ) ) ; ; ;G e t st h eX r e fP a t ht y p eu s e di nt h ex r e fa t t a c hd i a l o gb o x ; ; ;0=A b s o l u t eP a t h ; ; ;1=R e l a t i v eP a t h ; ; ;2=N oP a t h ( d e f u nG e t P a t h T y p e( ) ( v l l o a d c o m ) ( v l r e g i s t r y r e a d ( s t r c a t " H K E Y _ C U R R E N T _ U S E R \ \ " ( v l a x p r o d u c t k e y ) " \ \ P r o f i l e s \ \ " ( v l a g e t a c t i v e p r o f i l e ( v l a g e t p r o f i l e s ( v l a g e t p r e f e r e n c e s( v l a x g e t a c a d o b j e c t ) ) ) ) " \ \ D i a l o g s \ \ X a t t a c h D i a l o g " ) " P a t h T y p e " ) )

www.jtbworld.com/lisp.htm

9/10

9/17/13

LISP for AutoCAD - AutoLISP - Visual LISP

Home | Software | CAD | Blog

| Contact | About | Privacy Policy |

Sitemap | ^ Top of page

2001-2013 JTB World. All rights reserved.

www.jtbworld.com/lisp.htm

10/10

Вам также может понравиться