![]() |
![]() |
Back |
>Sean Horne wrote: > > I hope someone can help. > I am required to convert 3d plines to 2d pline. I have been using a lisp > routine which converts > the lines to a external DXF file. When I import the DXF file back into > AutoCAD and compare > the original 3d plines with the converted 2d plines it seems in accurate. > Is there another > lisp routine I can use that is more accurate or is there another method of > conversion > PS. were are using both R12 & R14 ToolPac 3.0 contains numerous conversion routines including 3D to 2D polylines, inside AutoCAD R12/R13/R14. Find out more at the URL below. +----------------------------------------------+ | DotSoft mailto:mailbox@dotsoft.com | +----------------------------------------------+ | Developers of ToolPac 3.0, a 300+ function | | productivity tool for all AutoCAD users. | | Visit http://www.dotsoft.com for details. | +----------------------------------------------+Return to Top
This is a multi-part message in MIME format. --------------257C99FE3A5EDEC9C4EB4C2A Content-Type: text/plain; charset=iso-8859-1 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Content-Transfer-Encoding: 8bit White Star wrote: > Does anyone know the feasibility of adding r12 IGES application to > r13? I strongly doubt that, since I couln´t even get IGES r13 to run under ACAD R13.Has anyone any idea concerning the "can´t load igesgui.arx" - problem ? Martin Sprengel -------------------------------------------------------------- Martin Sprengel Tel.: +49-431-597-2853 Arnold-Heller-Str. 16 Fax: +49-431-597-4042 D-24105 Kiel eMail:sprengel@mkg.uni-kiel.de Germany --------------257C99FE3A5EDEC9C4EB4C2A Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Sprengel, Martin Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Sprengel, Martin n: Sprengel;Martin org: Oral and Maxillofacial Surgery, Univ. of Kiel, Germany email;internet: sprengel@mkg.uni-kiel.de title: MD x-mozilla-cpt: ;0 x-mozilla-html: TRUE end: vcard --------------257C99FE3A5EDEC9C4EB4C2A--Return to Top
Hi, isn't there an AutoCAD FAQ ? I only found an AutoLisp FAQ... Any good tutorials and reference guides online ? Karel -- ======================================================================= Karel De Bruyne System/Network Manager phone + 32 3 820 22 04 UIA - Computer Centre fax + 32 3 820 22 49Return to Top
kevkem@epix.net says. faxing y work to my customers > I plot it ot a pcx, convert that to a fax with the invert option, and send the fax with a faxmodem card, ir R12.Return to Top
Hi Davide see htttp://hompages.ihug.co.nz/~bilro Regards to all Bill Le Couteur DavideReturn to Topwrote in article <5o8hac$56j$1@menelao.polito.it>... > If somebody can send me the addresses in internet to find some > intresting autolisp > Thank you very very very very much > >
Ron Flavell wrote: > > Has anyone out there written or know of a lisp routine to handle Xerox's > in a dialog box, or is there a command existing that I am over looking? Or > does anyone know if R14 has this built in? It would much handier to scroll > through a list and be able to edit them through a system similar to the > ddlmodes (layer dialog box) than through the text screen. Thanks. > -- > Ron Flavell > Product Designer/Programmer > rf@shenmfg.com Hi, Can't give you a lisp routine but r14 does handle xrefs with a NT/win95 style dialog. Cheers, Peter -- "Robbing a bank is nothing compared to owning one" - Brecht Peter Clark reply: clark@rmit.edu.au vox:+613 96 602 226 Faculty of the Constructed Environment fax:+613 96 632 891 RMIT University http://www.cfd.rmit.edu.auReturn to Top
This is a multi-part message in MIME format. --------------322385E88DF5BC94AC199EC4 Content-Type: text/plain; charset=us-ascii Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit Not a pro at lisp, but i think the state of layers vis-a-vis vports is a property of pspase vports. U can try accessing dxf codes of ps vports. David White wrote: > I want to find out the status of layers - whether frozen or not - > within > particular paperspace viewports and use this info to generate a list > of > layer names which I write to a file. > > Information about the freeze/thaw status of layers doesn't seem to be > retrievable via the tblsearch function and the only way I can get this > > info is via the (command "vplayer" "?" ) function which gives a > listing > to the screen of frozen layers within a selected viewport. I'm not > too > sure about how to direct this output to a text file using the > write-line > function. > > Is there another way? > > Thanks for your help, > > David White --------------322385E88DF5BC94AC199EC4 Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Rajesh Acharya Content-Disposition: attachment; filename="vcard.vcf" begin: vcard fn: Rajesh Acharya n: ;Rajesh Acharya email;internet: +raj2ras@emirates.net.ae note: Remove plus before address. x-mozilla-cpt: ;0 x-mozilla-html: FALSE end: vcard --------------322385E88DF5BC94AC199EC4--Return to Top
I have one program in autolisp ( mold librarie ) that works perfectely in autocad 13 C3, but now i made the upgrade to autocad 13 C4 and my autolisp program dont work, it says that is an invalid ARX aplication,Can anyone give me an help? Thanks for reading my message... send your tip to my e-mail please : agnelomelancia@mail.telepac.pt Thanks again...Return to Top
Hi AutoCAD experts, We contracted an organisation to develop some form of translator on AutoCAD so that data can be imported to AutoCAD. The program seemed to be working fine when AutoCAD was lauched and imported the first time. When we request for a new file without quitting AutoCAD and then import another file the performance deterioate a lot. We make sure all the memory are freed. Please advice. --Chi Hung chchan@gintic.gov.sgReturn to Top
Fully licensed commercial version of R4. Autodesk approved for licensed transfer. This is not a cheap educational copy. Make reasonable offer. Reply to vds@sedona.net attn:Jim Thank You jamReturn to Top
JAS wrote: > > I've only been getting 3-4 posts a day... Whazzup?! > -- > Jas Growney - I.S. Analyst > Butte County Public Works > Remove "_NO SPAM_" to return mail > or click here mailto:jas@shocking.com I cannot tell you what's wrong, but FYI I still get about 100 posts a day. MortenwReturn to Top
On 18 Jun 1997 02:26:47 GMT, "Brett Stufko"Return to Topwrote: >Does anyone have a simple utility that will allow a dos machine to connect >to my NT server so that I can copy the dos data to the server and share the >CD-ROM in order to install W95 across the network. > >Thanks > >Brett > Its easy Brett. On your NT CDROM there's a clients directory. Under there you'll find MS client 3.0, which is a quite workable version of LAN Manager for DOS. This supports access to NT via IPX, NetBEUI or TCP/IP. Simply create the 2 or 3 floppies and use INSTALL.EXE off the first one on your DOS machine.
Looking for AutoCAD Support files? AutoCAD Shareware Clearinghouse *** http://www.cadalog.com *** Try our New FAST! File finder. "Cold Fusion" SQL Database. Search by Partial Name or Keyword. 2226 AutoCAD Related files online! All Shareware & Freeware. LISP, Drivers, Fonts, Hatches, Blocks, Menus, Patches, Convertors, drawings, utilities, and everything related to AutoCAD.Return to Top
Mário Gomes wrote: > > I have one program in autolisp ( mold librarie ) that works perfectely in > autocad 13 C3, > but now i made the upgrade to autocad 13 C4 and my autolisp program dont > work, it says that is an invalid ARX aplication,Can anyone give me an help? Your application is not a lisp (or at least a part of your application is not), since ACAD is reporting invalid ARX application. An ARX is a compiled c++ code (or a lisp code compiled with Vital Lisp). Autodesk did a change in R13 between c3 and c4 that required ARX applications to be recompiled. Check with your developer for a c4 compatible ARX. Hope this helps, MortenwReturn to Top
In article <33A7975C.1B6E@pcug.org.au>, Jim says... > >I have been trying to print excel objects which have been pasted into >AutoCAD. All I get is blanks, does anybody know whats wrong? >-- >Jim McDougall >jmcdouga@pcug.org.au >06 2315008(h) 06 2613761(w) 06 2612979(f) Hi Configure your printer as systen printer and proceed. Hope this helps, Regards Sudheer O -- Sudheer O |Dr. DWG Products |http://www.cswl.com sudhee@cswl.com |OCX, Library and |1015 East Hillsdale Tel :(415) 3722900|Viewers for DWG |Boulevard, Suite 208 Fax :(415) 5778451|(R12 & R13) files|Foster City CA 94404Return to Top
david jose wrote: > > HELLO > I´M LOKING FOR CAD-CAM PROGRAMS(MASTER-CAM,SURF-CAM,ETC)WITH > CRACK FILE.IF ANBODY HAVE THIS STUFF CONTACT ME ON > david_jose@hotmail.com I want a new car just snail mail the keys and where pick it up. Thanks -- *************************************************************** * Dave Hinrichs E-Mail: dhinrichs@quannon.com * * Quannon CAD Systems, Inc. Voice: (612) 935-3367 * * 6101 Baker Road, Suite 204 FAX: (612) 935-0409 * * Minnetonka, MN 55345 BBS: (612) 935-8465 * * * * http://www.quannon.com/ * * * * My above address has been altered to prevent spamming * * remove the _delete_ to make it work. * ***************************************************************Return to Top
Architectural Draftsman Needed Small architectural firm located in Fairbanks, Alaska seeks architectural draftsman with a minimum of two years experience working on single family and multi-family residential projects, medium size hotel projects, and small to medium commercial projects. Autocad drafting experience desired but not mandatory for position. Knowledge of wood frame construction, project management experience, and the ability to work with professionals of other related design disciplines is highly desirable. Growth in firm is unlimited to the right individual willing to give long term commitment. Call (907)456-6713 or send resumes to Sumiko Heirston, P.O. Box 82472, Fairbanks, Alaska 99708 or email:raprice@polarnet.com.Return to Top
Powerless wrote: > > I have ACAD rel 13 C4 installed on my NT workstation. > > I notioce that the icons that correspond to ACAD drawings are the > "generic" windows icons rather than the standard ACAD icons. > > When I go into Explorer/View/Options, to edit the icons, the "change > icon" option is grayed out. > > I was just wondering if anyone has an explanation as to why I am > unable to change icons. > > Thanks! > > ______________________ > > '94 XLH 1200 > > http://www.tiac.net/users/greendm I don't know the answer but perhaps you should ask this on the MS NT workstation website as well as this one ? (if you haven't yet) ? I do know though that it doesn't happen with r14 and win 95... and also I didn't find anything to help in the MS Resource Guide or Pete Nortons NT Wkstn when I was wondering the same thing.. Cheers Peter -- "Robbing a bank is nothing compared to owning one" - Brecht Peter Clark reply: clark@rmit.edu.au vox:+613 96 602 226 Faculty of the Constructed Environment fax:+613 96 632 891 RMIT University http://www.cfd.rmit.edu.auReturn to Top
Did they show and architectural examples? Tell me more please. >On Thu, 19 Jun 1997 17:07:08 -0400, motleypcReturn to Topwrote: >Visio showed an alpha of a product called Phoenix. I spent some time >watching demos and working with it. It is 100% AutoCAD R14 with the >exception of Smart Snaps, as far as I can tell (Smartsnaps were licensed > >by Autodesk from Vellum). It also supports MDI, has true objects, and >better windows conventions. It uses native DWG files. You can type in >ANY AutoCAD R14 command and use it or you can use thier much improved, >but not nearly perfect, Windows interface. > >I was shocked it was this good... and so, evidently, was Carol Bartz... >she watched an entire presentation of the product with two VP's talking >in her ears explaining to her what she was seeing, I would guess. She >had earlier said that she felt this product was irrelevant because it >was R12... > >They are intending to sell the product for.............. $500!!!!! > >Way to go, John Forbes. > >Numerous third party ex Virtual Corporation vendors already have their >products up and running on Phoenix. It supports ARX, AutoLISP, and >Visual Basic for Applications.... my, my, my. The AYATOLLAHYOU was right > >all along. > >C# >
I'm looking for a group of routines that was on Compuserve (I think) about a year and a half ago. It was a surveying program that was dialogue box driven. It allowed you to select the way that you wanted to annotate your bearings and distances. It also had some linetypes like stone walls, fencing, etc. If anyone has this or knows where to get it, please e-mail me and let me know. Thanks Paul Jordan Fairbanks, AK -- jordan@santanet.comReturn to Top
Robert Daniels-Dwyer wrote: > > The answer to this is probably a straightforward 'no', but just in case: > > Is there a way to insert solids as blocks into a drawing in 13c4? > > If I create a block using a solid, and then insert the block, it ceases to > be a solid. Thus, it can;t be used in commands such as subtract and > massprop. This is a pain. Is there something that I have missed, or is > this just one of the quirks of AutoCAD? > > Thanks for your help. > > Robert Daniels-Dwyer > > Department of Archaeology, Tel: 0118 9875123 ext.7632 > University of Reading, e-mail: R.J.Daniels@rdg.ac.uk > England. http: //www.rdg.ac.uk/~lardanls/ Try inserting it as an XREF then bind and explode it. That was the r12 approach I can't say if it's the way for r13 though. -- | - - | # . . # Bob | [ > ] from | \_~_/ HiTech | _| |_Return to Top
Check the format options from the Dimension Styles dialog box. Where it says "fit:" Otherwise, if your dimension is associative, just highlight the grips and pull the arrows outside. Andrew Santo U...Return to Topwrote in article <33A68793.304E@hunterindustries.com>... > I currently just upgraded from Autocad r11 to r13. > Can anybody tell me why everytime I use a dia dimension and pick a > circle it always puts the dimension arrows inside. I tried changing > dimvar settings including dimtix to on. It didn't make any difference. > I would like to have the dimension arrow on the outside of the diameter. > Any help on this would be appreciated. > > Thanx >
just use the Windows NT Client. (LanMan) etc ! Adios ! Brett StufkoReturn to Topwrote in article <01bc7b90$1e9ddae0$8501d8cf@default>... > Does anyone have a simple utility that will allow a dos machine to connect > to my NT server so that I can copy the dos data to the server and share the > CD-ROM in order to install W95 across the network. > > Thanks > > Brett > >
Buy Software from the wholesalers and bypass the retail middleman. You could be saving $100's per software purchase. Buy anything direct. For more information, visit: http://www.a1.com/ajenterprisesReturn to Top
I hope someone can help I am required to convert 3d plines to 2d pline. I have been using a lisp routine which converts the lines to a external DXF file. When I import the DXF file back into AutoCAD and compare the original 3d plines with the converted 2d plines it seems in accurate. Is there another lisp routine I can use that is more accurate or is there another method of conversion PS. were are using both R12 & R14 Thanks in advance Seanh.Return to Top
> > Is there a way to insert solids as blocks into a drawing in 13c4? > > If I create a block using a solid, and then insert the block, it ceases to > be a solid. Thus, it can;t be used in commands such as subtract and Robert, try exploding it ONCE. It will then appear as a solid. If you like having the thng as a one piece thing, just union all the objects together. Regards to all Bill Le CouteurReturn to Top
New price, goto URL: http://www.mm.qnet.com/~zaxys/MDT_FS.htmlReturn to Top
clay wrote: > > How is it compared to R13c4a for NT 4.0 on Pentium 100 w/64MB RAM? smooth.. > Is it more stable? yes.. Is it less buggy? yes... Is it much faster? er, I'll probably get spanked for this but around 25 - 50%.. Does it make a big change in drawing file size containing many topographic contours does light polyline make a big difference - we do only civil drawing? yep, for sure.. > Will this upgrade benefit us? only you can answer that but I'd be very surprised if not... Cheers, Peter -- "Robbing a bank is nothing compared to owning one" - Brecht Peter Clark reply: clark@rmit.edu.au vox:+613 96 602 226 Faculty of the Constructed Environment fax:+613 96 632 891 RMIT University http://www.cfd.rmit.edu.auReturn to Top
Jim Mims wrote: > > > Thanks again for the responses, its nice to know that someone is > > listening? Does anyone have any ides on what good books are out there > > to learn AutoLISP from scratch? > > Anything by George Head is great! > > He also has a monthly column in Cadence. > > For the heavy duty (all inclusive) books, I would wait until the r14 books hit > the market. testReturn to Top
In article , "Owen says... > >Chris: > > The acad.exe is identical on all local language versions except US >Unlocked, Japanese, Chinese, and Korean versions. It's the support files >which differ. :) > >-- > Owen Wengerd [ManuSoft] > ** AutoCAD Wizard At Large ** > http://www.manusoft.com > owenw@manusoft.com > Compuserve: 71324,3252 > > >Chris NashReturn to Topwrote in article <5oalut$8ti$1@news5.gte.net>... >> Hi folks >> >> Can people do me a BIG favour? Could you mail me with the sizes of your >> acad.exe files, for as many versions of AutoCAD (windows!) as possible? >Also >> I'd like to see as many AutoCAD exe icons - I'm building a database to >> identify installed versions of AutoCAD. >> >> Best reply off the newsgroup to cnash@gte.net >> >> Thanks in advance, this would be a great help to me! >> >> Chris Nash >> beagle cad consulting >> Wow! It's nice to know you still can count on something. To Chris: Can you make your program to read "Modified" attribute of acad.exe? It's usually different for different versions of any software I guess and getting newer and newer (g).
I feel much the same way. I use it for plotting geological drawings in NE Nevada and find it much easier to scale my drawings correctly. I also use it for occasional architectural drawings. Ray ThompsonReturn to Top
Wirral CAE Services wrote: > > I am having problems setting up Artist Winsprint 1000 and 2000 Graphics > cards on Windows NT4 workstation. NT does not come with any built in > drivers and i can't seem to find a web site for Artist. Do they still > exist? Has anyone had any experience of setting these cards up or any > idea of the address of Artist's web site? Any help would be much > appreciated. > > Best regards > > Neil Hello Neil! They still exist, the adress is http://www.artgraphics.com/ they have the driver under development Regards AndreasReturn to Top
Mark R Payne wrote: > > Hi there, > > Does anyone out there have a LISP procedure that will insert a stream > direction arrow into a line? I am drawing a set of piping and > instrumentation diagrams, and obviously, I want to show which way the > fluid in the pipe is flowing -a LISP procedure to insert one at the > point that you select would be just great! > > Many thanks, > > Mark Payne Hi there Mark. Although I get the feeling of being suckered into a cruel joke here, I'm going to take a real gamble and ask you; Have you explored yet the full capabilities of AutoCAD's "insert" command? Now granted, it WILL require you to have a previously-drawn arrow on file, but then so would a Lisp routine. And you, the drafter, must do prior research as to the direction the flow is intended to be indicated in your piping drawing; But then a Lisp routine would require the same data. Hmmmm... I'm running out of possible reasons you would want a Lisp routine to do what the "insert" command should do nicely. Have I missed something here? Feel free to e-mail me if you need details on inserting flow-direction arrows in piping drawings, I've done hundreds. :^) With tongue burried deeply in cheek... Dennis.Return to Top
Nick Bogut wrote: > > Jimmy Brown wrote: > > > R13 has a problem with the incremental save feature. We had the same > > thing happening to our files. A small amount of editing would send a > > 500k file into the megabyte sizes. After setting the "isavepercent" > > variable to 0 (default setting is 50) our problems disappeared. > > > > Just type "isavepercent" (no quotation marks) at the command prompt > > and enter a setting of 0. This only has to be done once since it is > > a system variable not set in each file. > > > > Hope this helps. > > > > Jimmy Brown > > University of North Carolina > > Jimmy, > > I have a question regarding your suggestion. > > What is the con side of setting the "isavepercent" to 0? Surely, there > must be at least one. > > I have noticed the file balooning in the R13, as well, but I thought > it was due to other factors (handles, the ability of ACAD to > "remember" all the futile hatching attempts - wrong pattern, wrong > scale - you know, etc.). > > For example, killing the handles in R12 prohibits one from exporting > data to a spread sheet (I was told this - never tried myself). This > can be a problem for people spewing out stuff into Dbase, Excel, etc. > > Regards, > > Nick Bogut / nbogut@istar.ca The only problem is that it takes a little longer to save the drawing. Regard, AndreasReturn to Top
Posted-By: auto-faq 3.2.1.4a Archive-name: CAD/autolisp-faq/part2 URL: http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html Version: 1.8a Last-modified: 17.Jun 1997 Posting-Frequency: bi-weekly (every 2nd saturday) Copyright: see Appendix [A] Welcome to the comp.cad.autocad AutoLISP FAQ! by Reini UrbanAutoLISP is a scripting language for AutoCAD, a wellknown CAD package. This AutoLISP FAQ is posted to comp.cad.autocad, alt.cad.autocad and the *.answers groups bi-weekly. The (incomplete) AutoCAD FAQ is at http://www.cadence-mag.com/library/FAQ and not posted to comp.cad.autocad yet. The contents and the samples apply to all releases of AutoLISP since Release 10, including the third-party versions ACOMP and Vital Lisp. There's no special AutoLISP newsgroup. Source code of all functions in this FAQ is in FAQ-CODE.LSP (location see [A.1]), there's also a winhelp file. Thanks to all who have contributed. Corrections and contributions always welcome. This is part 2/2 of the AutoLISP FAQ, which consists of: AutoLISP FAQ (part 1/2) - general AutoLISP FAQ (part 2/2) - samples, code | changes, + new in items from this version to the last posted version, intermediate personal comments and uncertainties in {..} ----------------- Table of Contents ----------------- part 1: [0] The Future of AutoLISP? Should I learn it or VB instead? [1] Where can I find AutoLISP routines on the Internet? [1.1] Are the comp.cad.autocad articles stored somewhere? [1.2] AutoDESK's SDK [2] What are the best books to learn AutoLISP? [2.1] Online AutoLISP documents, Winhelp [2.2] AutoLISP Coding Style [3] How do I debug AutoLISP programs?" [3.1] Native AutoLISP debuggers [3.2] Modular style, TRACE [3.3] break function, debug print [4] How can I protect my AutoLISP programs? [4.1] Kelvinate [4.2] Protect [4.3] Kelvinate and Protect [4.4] Decrypt 2.0 / Convert 3.2 [4.5] acomp [4.6] Vital Lisp Pro [4.7] Lisp2C [5] AutoLISP compiler? [5.1] acomp | [5.2] Vital Lisp Pro [6] AutoLISP editors and other tools? [6.1] AutoLISP editors [6.2] Parenthesis checkers [6.3] Pretty Printers [7] AutoLisp problems and bugs (esp. with R13) [8] Sorting with AutoLISP [9] Recursion [10] Iteration with mapcar,... [11] My Lisp doesn't load at startup anymore + [12] How to Autoload my programs? [13] How can I pass a variable number of arguments to a lisp function? [14] How can I avoid stack overflows? [15] (command "ROTATE3D") does not work! Why? -- [A] Disclaimer, Notes from the author + [A.1] FAQ Locations part 2: [20] General helper functions [20.1] List manipulation [20.2] string manipulation + [20.3] symbol->string | [20.4] AutoCAD entity access [21] Sample Lisp programs: [21.1] Globally change texts, polylines, layer utils, datestamp + [21.2] Plot dialog from within Lisp. Using DDE [21.3] (entmod),(entmake) Layers, without (command "_LAYER"...) [21.4] How to select multiple files in Lisp? (as in FILES-Unlock) [21.5] Replace multiple blocks [21.6] (vports), VIEWPORT entity, pixel conversion [21.7] Select all visible objects: zoom coordinates [21.8] How to write XYZ data of selected objects to a file? [22] Block Attributes [22.1] How to access block attributes? [22.2] How to MODIFY block attributes? DATESTAMP.LSP [22.3] How to UPDATE block attributes? [22.4] How to ENTMAKE a Block Complex Entity in AutoLISP [23] Polylines [23.1] How to access polyline VERTICES? [23.2] How to JOIN multiple lines to polylines? [23.3] Change WIDTH of multiple polylines [23.4] Create a polyline or spline: with (ENTMAKE) or (COMMAND) | [23.5] How to calculate the LENGTH of polylines? [24] Circle/Arc Geometry: BULGE conversion, some trigonometry [25] DCL: listboxes with tabs or monotext font [26] EED Extended Entity Data: Get and Store [26.1] Select objects on their EED with (ssget "X") [26.2] Get EED from an object [27] How to break a command in Lisp? [28] How to decode ACIS internal geometry with Lisp? -- [A] Disclaimer, Notes from the author [A.1] FAQ Locations [B] Acknowledgements [C] Recent Changes ---------------------------------------------------------------------- Subject: [20] General helper functions There doesn't yet exist free libraries for i.e. basic list and string manipulation as for any other lisp. You have to collect these by your own. Some code is available at some AutoLISP sites [1] or included in the SDK's by AutoDESK [1.2] I included here some very useful helper functions for shorter samples in answers on the net. You could rely on the fact that these functions are in common knowledge such as the famous dxf function, which is defined as (defun dxf (grp ele) (cdr (assoc grp ele))) and the specific counterpart of (getval) which works with every entity type. [20.1] List manipulation Useful sample functions for *list manipulation* are: ;;; CONSP - a not empty lisp (defun consp (x) (and x (listp x))) ;;; POSITION - returns the index of the first element in the list, ;;; base 0, or nil if not found ;;; (position x '(a b c)) -> nil, (position b '(a b c d)) -> 1 (defun position (x lst / ret) (if (not (zerop (setq ret (length (member x lst))))) (- (length lst) ret))) ;;; REMOVE - Removes an item from a list (double elements allowed) ;;; (remove 0 '(0 1 2 3 0)) -> (1 2 3) (defun remove (ele lst) ; by Serge Volkov (apply 'append (subst nil (list ele) (mapcar 'list lst)))) ;;; REMOVE-IF - Conditional remove from flat list, ;;; pred requires exactly 1 arg ;;; (remove-if 'zerop '(0 1 2 3 0)) -> (1 2 3) ;;; (remove-if 'numberp '(0 (0 1) "")) -> ((0 1) "") (defun remove-if (pred from) (cond ((atom from) from) ;nil or symbol (return that) ((apply pred (list (car from))) (remove-if pred (cdr from))) (t (cons (car from) (remove-if pred (cdr from)))) ) ) ;;; REMOVE-IF-NOT - keeps all elements to which the predicate applies ;;; say: "keep if", it need not be defined recursively, also like this (defun remove-if-not (pred lst) ; by Vladimir Nesterowsky (apply 'append (mapcar '(lambda(e) (if(pred e)(list e))) lst))) ;;; ADJOIN - conses ele to list if not already in list ;;; trick: accepts quoted lists too, such as ;;; (setq l '(1 2 3) (adjoin 0 'l) ;;; -> !l (0 1 2 3) (defun adjoin (ele lst / tmp) (if (= (type lst) 'SYM) (setq tmp lst lst (eval tmp))) (setq lst (cond ((member ele lst) lst) (t (cons ele lst)))) (if tmp (set tmp lst) lst) ) ------------------------------ [20.2] string manipulation Some useful *string functions* would be: predicates: (stringp expr) - string predicate, is expr a string? (defun stringp (s) (= (type s) 'STR)) (string-not-emptyp str) - is str a not empty string? (defun string-not-emptyp (s) (and (stringp s) (/= s ""))) trimming: (str-trim string) - str without any whitespace, to the right and left, defined in AI_UTILS.LSP as well as (str-left-trim string), (str-right-trim string) (str-left-trim-bag string bag), (str-right-trim-bag string bag) - remove all chars in bag (=STR) string access: (strpos string substr) - position of substring in string (1 based) parsing and gathering functions, (list<->string) such as: (strtok str tokens) - string -> list delimited by tokens (SDK2) (strlcat lst delim) - concat list -> string seperated by delim (string->list str) - string -> list of chars (list->string lst) - list of chars -> string Some are at http://xarch.tu-graz.ac.at/autocad/code/vnestr/strtok.lsp or in your AI_UTILS.LSP. You'll need them esp. for DCL functions. ------------------------------ [20.3] symbol->string The inverse function to (read) would be (symbol-name). Don't ask why, but the following is the only general way: ;;; SYMBOL-NAME - returns the name of a symbol as string ;;; converts any valid lisp expression to its printed representation ;;; (symbol-name a) -> "a", (symbol-name '(0 1 2 a)) -> "(0 1 2 A)" (defun symbol-name (sym / f str tmp) (setq tmp "$sym.tmp") ;temp. filename, should be deleted (setq f (open tmp "w"))(princ sym f) (close f) (setq f (open tmp "r") str (read-line f) f (close f)) str ) For plain symbols exists a better trick explained by Christoph Candido at http://xarch.tu-graz.ac.at/autocad/news/symbol-string.txt ------------------------------ [20.4] AutoCAD entity access ;;; returns the first group value of an entity. ;;; like the wellknown (dxf) function but accepts all kinds of ;;; entity representations (ename, entget list, entsel list) ;;; NOTE: For getting 10 groups in LWPOLYLINE's not usable! (defun GETVAL (grp ele) ;"dxf value" of any ent... (cond ((= (type ele) 'ENAME) ;ENAME (cdr (assoc grp (entget ele)))) ((not ele) nil) ;empty value ((not (listp ele)) nil) ;invalid ele ((= (type (car ele)) 'ENAME) ;entsel-list (cdr (assoc grp (entget (car ele))))) (T (cdr (assoc grp ele))))) ;entget-list ;;; Ex: (gettyp pline) => "POLYLINE" (defun GETTYP (ele) ;return type (getval 0 ele)) ;;; assure ENAME ;;; convert the entity to type ENAME (to write shorter code) (defun ENTITY (ele) ;convert to element name (cond ;accepts the following types: ((= (type ele) 'ENAME) ele) ; ENAME ((not (listp ele)) nil) ; error: no list ((= (type (car ele)) 'ENAME) (car ele)) ; entsel-list ((cdr (assoc -1 ele))) ; entget-list or nil ) ) ;and now just: (bugfixed) | (defun getval (grp ele) (cdr (assoc grp (entget (entity ele))))) ;;; Ex: (istypep ele "TEXT") ;;; is element a "SOLID"? (defun istypep (ele typ) ;check type (= (gettyp ele) typ)) ;;; Ex: (istypep ele '("TEXT" "ATTDEF")) ;;; is element a "TEXT" or a "ATTDEF"? (defun ISTYPEP (ele typ) ;better implementation to accept lists too (cond ((listp typ) (member (gettyp b) typ)) ((stringp typ) (= (gettyp b) typ)) ;assume typ uppercase (T nil))) ;;; Ex: (getpt (entsel)) => ( 0.1 10.0 24) (defun GETPT (ele) ;return the startpoint of any element (getval 10 ele)) ;group 10 ;;; Ex: (getflag pline) => 1 if closed (defun GETFLAG (ele) (getval 70 ele)) ;same with the entity flag ;;; bitvalue val in flag of element set? ;;; Ex: (flagsetp 1 pline) => T if closed ;;; Ex: (flagsetp 16 vertex) => T if spline control point (defun FLAGSETP (val ele) (bitsetp val (getflag ele))) ;;; Ex: (bitsetp 4 12) => T ;bitvalue 4 (=2.Bit) in 12 (=4+8) is set (defun BITSETP (val flag) (= (logand val flag) val)) ;;; convert selection set to list, ;;; Note: it's also wise to use ai_ssget, because some ents could be ;;; on locked layers ;;; Ex: (sslist (ai_ssget (ssget))) => list of selected unlocked ents ;;; or (mapcar 'entupd (sslist (ssget "X" '((8 . "TEMP"))))) ;;; - regens all entities on layer TEMP (defun SSLIST (ss / n lst) (if (= (type ss) 'PICKSET) (repeat (setq n (sslength ss)) (setq n (1- n) lst (cons (ssname ss n) lst))))) ;;; apply a function to each ent in ss, in reversed order ;;; Faster, but not so easy to understand. see [22.2] ;;; Ex: (ssapply 'entupd (ssget)) ; regenerate only some entities (defun SSAPPLY (fun ss / n) (if (= 'PICKSET (type ss)) (repeat (setq n (sslength ss)) (apply fun (list (ssname ss (setq n (1- n)))))))) ------------------------------ Subject: [21] Sample Lisp Programs: [21.1] Globally change texts, polylines, layer utils, datestamp For globally changing text attributes use CHTEXT.LSP in your sample directory. For globally changing polyline attributes, freeze layers by pick and other similar tasks search for free lisp tools at any AutoLISP site. See "[1]" and some code at "[22]","[23]","[24]" For putting a datestamp and others onto your plots automatically first check out if your plotter supports HPGL/2. Then use the internal HPGL/2 driver and configure the datestamp in HPCONFIG. DATESTAMP.LSP: Change the plot header attributes by yourself as in [22.2]. A profi plotstamp routine is here: http://ourworld.compuserve.com/homepages/tonyt/plotstmp.htm ------------------------------ [21.2] Plot dialog from within Lisp. Using DDE [updated] Calling the PLOT dialogbox from AutoLISP is possible only under Windows i.e. with LISPPLOT by Mike Dickason. This feeds the keyboard buffer with keystrokes. http://www.cadalog.com/cadalog/files/lispd-l/lspplw.zip or also: ftp://ftp.mcwi.com/pub/mcwi/lisp/winplt.lsp Otherwise create a script and call this at the end of your lisp, but this will not show up the dialogbox. Xiang Zhu: You can use "ddelisp.exe" from R12/R13 of Windows version to do something like the following: (defun ddecmd (str / tmp) (if (not initiate) (xload "ddelisp")) (if (not (zerop (setq tmp (initiate "autocad.r13.dde" "system")))) (progn (execute tmp (strcat "[" str "]")) (terminate tmp) str)))) For R12 use "autocad.dde" as the server name. Then, inside your lisp or script, you can do (ddecmd "_plot "). Function DDECMD will return nil if something wrong, or the string you passed if successful. The string is just like what you type under the command prompt from keyboard, so you need put a space or a return, which is "^13" here, to end the string. Besides, the function is very useful in the following situation: If within a lisp, you need call an AutoCAD transparent command like LAYER, normally you will use (command "_layer"), but after use this line, the lisp own will not be transparent. Using the function, you will solve this problem. ------------------------------ [21.3] (entmod) and (entmake) Layers, without (command "_LAYER"...) ENTMOD a layer I try to change a layer property without calling COMMAND function inside a lisp routine. Under r13, using the following lisp (setq tbl_lst (entget (tblobjname "LAYER" "ANY_LAYER")) clr_grp (assoc 62 tbl_lst) ) (entmod (subst (cons 62 (- (cdr clr_grp))) clr_grp tbl_lst)) you can toggle "ANY_LAYER" On or Off, even it is the current layer. But AutoCAD doesn't know a table entry has been changed until you click the Layer Control on the toolbar or something similar. Besides, you can issue 'DDLMODES to see On/OFf property of "ANY_LAYER" changed. Doing the same way to freeze a layer, you will still see entities on that layer shown on screen, but you can not select them, until you do something related to layer settings, and AutoCAD will hide those entities. ENTMAKE a layer You must get your pattern with entget, using the table object name as argument. This table object name can be retrieved with the TBLOBJNAME function: (entget (tblobjname "LAYER" "ANY_LAYER_NAME")) ;;; This routine will create a layer with any name you type: (defun c:mlay () ; by Reinaldo Togores (setq laynam (getstring "\nLayer name: ")) (entmake (list '(0 . "LAYER") '(5 . "28") '(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord") (cons 2 laynam) '(70 . 64) '(62 . 7) '(6 . "CONTINUOUS") ) ) ) ------------------------------ [21.4] How to select multiple files in Lisp? (as in FILES - Unlock) At http://xarch.tu-graz.ac.at/autocad/progs/MGETFILD.ZIP is a lisp helper routine to select multiple files with DCL. You will also need DOSLIB from McNeel to access the dos specific directory functions. http://www.mcneel.com/mcneel/doslib.html ------------------------------ [21.5] Replace multiple blocks A search at the lisp archives yielded those hits: Cadalyst: http://www.cadonline.com/search.phtml => 97code.htm and a question for your username which can be obtained free and automatically or xarch: http://xarch.tu-graz.ac.at/autocad/code and search for "BLOCK;REPLACE" => http://xarch.tu-graz.ac.at/autocad/code/cadalyst/94-02/replace.lsp also at the Cadalog: http://www.cadalog.com/find.htm Keyword "Block Replace" => http://www.cadalog.com/cadalog/files/lispr-z/replace.zip (this one is the best) ------------------------------ [21.6] (vports), VIEWPORT entity, pixel conversion VIEWPORT entity: The answer to "I can do an (entget) on a VIEWPORT and get its lower left (DXF group 10) and upper right (DXF group 11) corner. But it appears that these coordinates are in the paper space system. What I'm interested in finding out is what portion of the "real" drawing (the model space drawing) are currently shown in that viewport." is at http://xarch.tu-graz.ac.at/autocad/news/vports.lsp How to change viewports in AutoLISP? with (setvar "CVPORT" vport-id) see http://xarch.tu-graz.ac.at/autocad/news/change_vports.html With the following functions you convert pixel<->drawing units: ;;; Conversion pixel to drawing units (defun PIX2UNITS (pix) (* pix (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE"))))) ;;; Conversion drawing units to pixel (defun UNITS2PIX (units) (* units (/ (cadr (getvar "SCREENSIZE"))(getvar "VIEWSIZE")))) ------------------------------ [21.7] Select all visible objects: zoom coordinates Beware that with (ssget) you will only get visible objects, because all interface functions (entsel,ssget,osnap) work with pixel, only (ssget "X") will select not visible objects. ;;; returns a list of the actual viewport corners in WCS (defun zoompts ( / ctr h screen ratio size size_2) (setq ctr (xy-of (getvar "VIEWCTR")) ;3D -> 2D h (getvar "VIEWSIZE") ;real screen (getvar "SCREENSIZE") ;2D: Pixel x,y ratio (/ (float (car screen)) ;aspect ratio (cadr screen)) size (list (* h ratio) h) ;screensize in coords size_2 (mapcar '/ size '(2.0 2.0))) (list (mapcar '- ctr size_2) (mapcar '+ ctr size_2))) (defun xy-of (pt) (list (car pt)(cadr pt))) ;assure 2D coords Note: The points returned are in WCS but this is ok, because the "CP" "WP" and "P" options of ssget expect WCS points. "W" and "C" require UCS points - why the difference I don't know. ;;; one way to define this function (defun ssall-visible (/ l) (ssget "C" (car (setq l (maptrans0-1 (zoompts)))) (cadr l))) ;;; or another (defun ssall-visible-1 () ;combine "C" and (p1 p2) to one list (apply 'ssget (append '("C") (maptrans0-1 (zoompts))))) ;;; map some pts from UCS to WCS, easier with just one argument (defun maptrans0-1 (pts)(mapcar '(lambda (pt)(trans pt 0 1)) pts)) ------------------------------ Subject: [21.8] How to write XYZ data of selected objects to a file? ;;; CDF - comma delimited string (defun cdf-point (pt) (strcat (car pt) ", " (cadr pt) ", " (caddr pt))) ;;; SDF - space delimited, may easier be read back in to AutoCAD (defun sdf-point (pt) (strcat (car pt) " " (cadr pt) " " (caddr pt))) ;;; convert this SDF format back to a point with (defun str->point (s) (eval (read (strcat "(" s ")")))) ;;; Write a XYZ file of all selected objects (SDF see below) (defun C:XYZ (/ ss fname f) (if (and (setq ss (ssget)) (setq fname (getfiled "Write XYZ to file" (strcat (getvar "DWGNAME") ".XYZ") "XYZ" 7)) (setq f (open fname "w"))) (foreach ele (sslist ss) ; -> [20.4] (foreach pt (getpts ele) ; -> [23.1] (write-line (cdf-point pt) f) ) ) ) (if f (close f)) ) ;;; => .xyz ;;; 0.45, 12.3, -34.0 For a ASC file (SDF-format) simply change all XYZ to ASC and cdf-point to sdf-point above. For the other way 'round, creating PLINES from a ascii x,y file best convert the file to a script like: PLINE 300.2,10 350.4,10.4 ------------------------------ Subject: [22] Block Attributes [22.1] How to access block attributes? Check all subentities after the INSERT until the attribute is found. See also http://www.autodesk.com/support/techdocs/acadcdi/td300518.htm -> "Retrieving Complex Entities and Sub-entities with AutoLISP" ;;; returns entget-list of attribute attname (STRING) in element ele ;;; or nil if not found (defun attele (ele attname / rslt) (if (and (istypep ele "INSERT") (= (getval 66 ele) 1)) (progn (setq ele (entnext (entity ele))) (while (istypep ele "ATTRIB") (if (= (strcase (getval 2 ele)) (strcase attname)) (setq rslt (entget ele) ele nil) ;break the loop (setq ele (entnext ele)) ) ) ) ) rslt ) ;;;Example: (attele (entsel) "TEST") ; returns entget-list of ; attribute "TEST" if the block has it BTW: Even trickier functions to get entities DXF group codes are GET and EDLGETENT by Vladimir Nesterowsky. ;;;Sample calls: ;;; return list of 2,1 and -1 group values (defun get-attribs-look-up( block-ename ) (get '(2 1 -1) (cdr(edlgetent block-ename)))) (defun all-verticies-and-bulges( pline-ename ) (get '(10 42) (cdr(edlgetent pline-ename)))) available at http://xarch.tu-graz.ac.at/autocad/code/vnestr/ ------------------------------ [22.2] How to MODIFY block attributes? DATESTAMP Simply entmod the entget-list retrieved from (attele) as above. ;;; change the attribute value of INSERT ele to new (group 1) (defun ATTCHG (ele attname new / b) (if (setq b (attele ele attname)) (entmod (subst (cons 1 new) (getval 1 b) b)))) ;;; Change all DATESTAMP attributes in all inserted PLOT* blocks (defun C:DATESTAMP () (ssapply (ssget "X" '((0 . "INSERT")(2 . "PLOT*"))) '(lambda (ele) (attchg ele "DATESTAMP" (today)) (entupd ele) ))) ;;;return todays date, could be a DIESEL or this string conversion (defun today (/ s) (setq s (rtos (getvar "CDATE") 2)) ;gets the julian date (strcat (substr s 5 2) "-" (substr s 7 2)"-"(substr s 3 2))) ------------------------------ [22.3] How to UPDATE block attributes? There exists a SUPPORT\ATTREDEF.LSP to update attribute properties (position, layer, ...) for already inserted blocks. On complex entities you must (entupd) the header entity, to see the update on the screen (forces an element REGEN). ;;; Example: (setq s (getstring "Change Attribute to: ")) (attchg (attele (setq b (entsel "of block: ")) s))) (entupd (car b)) ; the block, not the attribute ;;; some more helper funcs to get the main entity of any attribute ;;; or vertex (defun main-entity (ele) (setq b (entity b)) ;force ENAME (while (istypep b '("ATTRIB" "ATTDEF" "VERTEX")) (setq b (entnext b))) ;loop until no more sub-ents (if (istypep b '("SEQEND" "ENDBLK")) (getval -2 b) ;complex entity -> header b ;normal entity ) ) ------------------------------ [22.4] How to ENTMAKE a Block Complex Entity in AutoLISP see http://www.autodesk.com/support/techdocs/acadcdi/td300515.htm There is an example how to use multiple calls to (entmake) to create the block header, the entities, closes the block and finally (entmake) the INSERT. For anonymous blocks beware that only (setq bn (entmake '((0 . "ENDBLK")))) returns the blockname for (entmake (list '(0 . "INSERT")(cons 2 bn) ...)) ------------------------------ Subject: [23] Polylines R14 LWPOLYLINE's store the vertices in one entity as multiple 10 groups. [23.1] How to access polyline VERTICES? A polyline VERTEX is a subentity of a POLYLINE (same as an ATTRIBUTE is a subentity of an INSERT element or a ATTDEF of a BLOCK). Therefore the same functions as in [22.1]-[22.3] can be used. ;;; return the vertex list of a polyline or of any other element ;;; Note that with edlgetent mentioned in [22.1] it's a one-liner (defun getpts (ele / pts) (cond ((istypep ele "POLYLINE") (while (not (istypep (setq ele (entnext ele)) "SEQEND")) ;;omit fit and spline points (conservative style) (if (not (or (flagsetp 1 ele) (flagsetp 8 ele))) ;bugfix! (setq pts (cons (getpt ele) pts)) ) pts ) ) ;; special case: you have to map it, assoc finds only the first ((istypep ele "LWPOLYLINE") (apply 'append (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) ;group 10 only (entget (entity ele))))) ;; insert here possible other types, such as ((istypep ele '("TEXT" "CIRCLE")) (list (getpt ele))) ;; more like this (serge's style) (T (apply 'append (mapcar '(lambda (n / p) (if (setq p (getval n ele)) (list p))) '(10 11 12 13))) ) ;; or like this (conservative style) ;;(T (foreach n '(10 11 12 13) ;; (if (setq p (getval n ele)) (setq pts (cons p pts)))) ;; pts ;;) ) ) Suggestions by Vladimir Nesteroswky for a different vertex structure: (defun vertices-and-bulges (pline-ename) (mapcar 'cdr (remove-if-not '(lambda (ele) (bitsetp 9 x)) (get '(70 10 42) (cdr (edlgetent pline-ename)) => list of (10 42) pairs of the pline see also [23.5] for a different edge structure (segments) of plines. ------------------------------ [23.2] How to JOIN multiple lines to polylines? Simply try to join each element with all selected, but beware that an entity already joined cannot be entget'ed anymore, because it's deleted. ;;; This sample converts all selected elements to polylines and ;;; tries to join as much as possible. (defun C:JOINPOLY (/ ele ss) (foreach ele (sslist (setq ss (ssget))) ;better process lists (if (entget ele) ;not already joined (cond ;(then it would be nil) ((istypep ele '("ARC" "LINE")) ;; in fact you should check Z of lines and UCS here too (command "_PEDIT" ele "_Y" "_J" ss "" ""); convert and JOIN ) ((and (istypep b '("POLYLINE" "LWPOLYLINE")) (not (flagsetp 1 ele)) ;not closed (< (rem (getflag ele) 128) 8)) ;ignore meshes and such (command "_PEDIT" ele "_J" ss "" "");ucs check omitted ) ) ) ) ) ------------------------------ [23.3] Change WIDTH of multiple polylines With the help of the above defined helper function it's a short one: (defun C:POLYWID (/ wid ele) (initget 5)(setq wid (getdist "New Polyline Width: ")) ;not negative (foreach ele (sslist (ssget '((0 . "*POLYLINE")))) ;only PLINES (command "_PEDIT" ele "_W" wid ""))) ------------------------------ [23.4] Create a polyline or spline: with (ENTMAKE) or (COMMAND) 1. You can create a script-file with a LISP-program and then run it. It seems to be the simpliest way, but I/O errors may occur when reading/writing the script. If your soft is commercial, it must handle such errors. 2. The second way is to create the entities list and use ENTMAKE. Advantage: fast, in WCS, independent of actual osnaps. see http://www.autodesk.com/support/techdocs/acadcdi/td300510.htm 3. The third solution is based on command and mapcar. It works with Polylines, Splines or Lines. Disadvantage: UCS, Osnaps ;;; Draws a POLYLINE entity from a list of points (same with SPLINE, ;;; or LINE), on the actual UCS, with actual OSNAP settings (defun DRAW-PLINE (pts) (command "_PLINE") (mapcar 'command pts) (command "")) (defun DRAW-SPLINE (pts) (command "_SPLINE") (mapcar 'command pts) ; the pts must be the fitpoints then (command "" "" "")) ------------------------------ | [23.5] How to calculate the LENGTH of polylines? There are two ways: 1. the obvious, using the AREA command which is quite "noisy" (prints the result), but works even with splines. ;;; add up the LENGTH of all selected objects, NOISY, you can do the ;;; same with AREAs: simply change the last line to (getvar "AREA") (defun C:LEN-OF () (command "_AREA" "_A" "_E") ;add up objects (for R12+13) (ssapply 'command (ssget)) ;pass all elements to AutoCAD (command "" "") ;two returns (getvar "PERIMETER")) ;this is the length 2. Doing some math, but only for simple entities. Here it is best to define some helper functions again. This is also an introduction for the next chapter [24], some bulge trigonometry for curved segments. ;;; calculates length of a pline, quiet (defun poly-length (poly / seg) (apply '+ ; the sum of all single segment lengths (mapcar '(lambda (seg) ;length of one segment (if (zerop (car seg)) ;is it straight? (distance (cadr seg) (caddr seg)) ; line segment or (abs (arclen seg)) ; curved: -> [24] ) ) (pline-segs poly)))) ;segment list (bulge p1 p2) ;;; creates a segment list for the polyline pname ;;; as a list of '(bulge p1 p2). a straight line has bulge 0.0 ;;; compute pts in ECS of pname. ;;; Does NOT work with the new LWPOLYLINE yet. Ignores them now. (defun pline-segs (pname / b line segs first) (setq b (entity pname)) ; for type-safety (while (istypep (setq b (entnext b)) "VERTEX") ;changed for R14 (if (not (flagsetp 16 b)) ; ignore this (if first (setq segs (cons ;lineseg: list of '(bulge p1 p2) (reverse (cons (trans (getpt b) 0 pname) line)) segs) line (list (trans (getpt b) 0 pname) (getval 42 b)) ) (setq first (trans (getpt b) 0 pname) ;only called once line (list first (getval 42 b)) ) ) ) ) (if (flagsetp 1 pname) ; closed polyline? (setq segs (reverse (cons (reverse (cons first line)) segs))) (setq segs (reverse segs)) ) segs ) ;;; Example: (a bit optimized for brevity :) ;;; Add up all the lengths of all selected polylines, quiet ;;; To accept also other entities, add those to pline-segs (defun C:POLYLEN () (apply '+ (ssapply 'poly-length (ssget '((0 . "POLYLINE")))))) For the sum of areas use either the noisy AREA command or implement heron's formula for polygon areas (just for simple closed polygons). ------------------------------ + [23.6] How to revert a polyline direction? Sergei Komarov submitted a REVPOLY.LSP which takes care of bulges and widths too. http://xarch.tu-graz.ac.at/autocad/news/lisp_pro/revpoly.lsp ------------------------------ Subject: [24] Circle/Arc Geometry: BULGE conversion, some trigonometry What is the *BULGE* in a polyline? The bulge is the tangent of one forth of the included angle of a curved segment. A bulge 0.0 means a straight segment. Together with the start- and endpoint it is sufficient information to quickly calculate all other required information of a curved segment. arclength = radius*angle bulge = tan(ang/4) (ccw: +, cw: -) angle = 4*atan(bulge) bulge = (2*altitude) / chord (ccw: +, cw: -) see also http://www.autodesk.com/support/techdocs/lisp/fax797.htm for a sample program or the book "Maximizing AutoLISP" [2] ;;; SEG2CIR - converts a bulged segment (bulge pt1 pt2) of a polyline ;;; to a circle (ctr rad), the start- and endpoints are known ;;; therefore the angles too: (angle ctr pt1)(angle ctr pt2) ;;; returns nil on a straight segment! ;;; (bugfixed version. Thanks to Sergei Komarov) (defun seg2cir (seg / bulge p1 p2 cot x y rad dummy) (if (zerop (car seg)) ;straight line => invalid circle nil (setq bulge (car seg) p1 (cadr seg) p2 (caddr seg) cot (* 0.5 (- (/ 1.0 bulge) bulge)) x (/ (- (+ (car p1) (car p2)) (* (- (cadr p2) (cadr p1)) cot)) 2.0) y (/ (+ (+ (cadr p1) (cadr p2)) (* (- (car p2) (car p1)) cot)) 2.0) rad (distance (list (car p1) (cadr p1)) (list x y)) dummy (list (list x y) rad)))) ; return this, I hate progn's ;;; ARC2SEG - inverse conversion ;;; calculates segment (bulge p1 p2) of arc ;;; with given circle (ctr rad), start-angle, end-angle (defun arc2seg (cir ang1 ang2 / p1 p2) (setq p1 (polar (car cir) ang1 (cadr cir)) p2 (polar (car cir) ang2 (cadr cir))) (list (arc2bul p1 p2 cir) p1 p2)) ;;; ARC2BUL - calculates bulge of arc given the arc points and the ;;; circle (ctr rad) (defun arc2bul (p1 p2 circle / ang) (tan (/ (- (angle (car cir) p2) (angle (car cir) p1)) 4.0))) ;;; BUL2ANG - returns angle of arc (bulge) (defun bul2ang (seg / ctr) (- (angle (setq ctr (car (seg2cir seg))) (cadr seg)) (angle ctr (caddr seg)))) ;;; ARC2ANG ;;; calculates angle of arc given the chord distance and radius (defun arc2ang (chord rad) (* 2.0 (atan (/ chord 2.0 (sqrt (- (expt rad 2) (expt (/ chord 2.0) 2) ) ) ) ) ) ) ;another way in the paren's world ;;; ARCLEN - length of arc = radius*angle, ;;; Note: +-, you'll need (abs (arclen seg)) for the distance (defun arclen (seg) (* (cadr (seg2cir seg)) ;radius 4.0 (atan (car seg)))) ;angle = 4*atan(bulge) (defun tan (x) (/ (sin x)(cos x))) (defun dtr (ang)(* pi (/ ang 180.0))) ;degree to radian (defun rtd (ang)(/ (* ang 180.0) pi)) ;radian to degree ------------------------------ Subject: [25] DCL: listboxes with tabs or monotext font In Windows it's difficult to layout texts because of non-monospaced fonts. Try it with the tabs attribute in the list_box tile, such as: tabs = "0 20 40"; and (set_tile "listbox" "Layer:\t0\twhite") try the following to use monospaced characters: : list_box { label = "Drawing"; key = "dwglist"; width = 50; fixed_width_font = true; // <- monotext } Also have a look at the detab routine at http://xarch.tu-graz.ac.at/autocad/news/detab.lsp {not yet} ------------------------------ Subject: [26] EED Extended Entity Data: Select, Get and Store [26.1] Select objects on their EED with (ssget "X") ;;; defines your appname header and delimiter (4 char regapp name ;;; according AAIG, AutoDESK Application Interoperation Guidelines) (setq appname "HUBU-") ;;; defines * for all sub types (setq allappnames (strcat appname "*")) ;;; eg: HUBU-LIST1, HUBU-LIST2 ;;; here is how to get the first eed list from one element (defun get-eed-1st (ele) (cdadr (assoc -3 (entget (entity ele) (list allappnames))))) ;;; this gets all elements of appnames typ (wildcards allowed) (defun ssget-app (typ) ;fast (ssget "X" (list (list -3 (list typ)))) ;;; this gets only your elements (defun ssget-hubu (typ) ;fast (ssget "X" (list (list -3 (list (strcat appname typ))))) (ssget-hubu "*") ; will get all your elements ------------------------------ [26.2] Get EED from an object Check any XDATA with: (entget (car (entsel)) '("*")) ;;; GETXDATA - get all XDATA lists from an element ;;; i.e with XDATA: ;;; (-3 ("HUBU-1" (1000 ."ASSHATCH")(1002 ."{") ;;; (1070 . 1)(1002 ."}"))) ;;; =>(("HUBU-1" (1000 ."ASSHATCH")(1002 ."{")(1070 . 1)(1002 ."}"))) (defun getxdata (e apnlst) (cdr (assoc -3 (entget e apnlst)))) ;;; GETXDATA-ALL - all lists without the regapp name ;;; => ((1000 ."ASSHATCH")(1002 ."{")(1070 . 1)(1002 ."}")) (defun getxdata-all (e apnlst) (apply 'append (mapcar 'cdr (getxdata e apnlst)))) The regapp name is stripped here, because it's only used for fast ssget access. The different apps are divided by different (1000 . name) groups. For storing XDATA in an element see XDATA.LSP or XED.LSP though those examples are a bit disturbing. For advanced EED tricks, esp. converting the "{" "}" ADS resbuf style to Lisp lists and back, see http://xarch.tu-graz.ac.at/autocad/news/eed_retrieval.txt ------------------------------ Subject: [27] How to break a command in Lisp? Also: "How do I press Break in AutoLISP?" (command) without parameters works just like hitting Ctrl-C in R12 or Esc in R13 at the command prompt. But it does not mimic Esc in a dialog box. And it does not work within SCRIPTS. (command nil) is the same as (command). (command) breaks only the command functions, e.g. if you use the command "DIM" inside AutoLISP, you must interrupt it by (command) after dimensioning. But it doesn't work, if you try to interrupt a lisp loop. There is another function (exit) or (quit) -they do the same-, which immediately break a Lisp program. Example: (while T ; do ; a never ending loop (princ "\nEnter a=") (setq a (getint)) (if (zerop a)(exit)) ; Breaks Lisp and returns to the command mode. ) In this example (command) doesn't work. (exit) works exactly as Ctrl-C. It prints "error: quit / exit abort" and outputs all nested functions. To provide "silent" break you must include this error message to an error handling function, e.g.: (setq olderr *error* *error* my_error) (defun my_error (s) (if (not (member s ; msgs of the english version: '("Function cancelled" "console break" "quit / exit abort"))) (princ (strcat "\nError: " s)) ) (setq *error* olderr) ) For scripts use this workaround by defining (cancel) in lisp, simply (defun cancel() (command) (command "resume") ) and SCRIPT.SCR: .. [