arulmozhi Posted November 9, 2008 Share Posted November 9, 2008 I am beginner to lisp. I'm in need of a program to calculate and print areas of undefined regions. So I want a lisp program to make region, calculate area and print the area with required decimal places wherever we want in the drawing area. Please help and post some lisp routines. Quote Link to comment Share on other sites More sharing options...
lpseifert Posted November 9, 2008 Share Posted November 9, 2008 Here's one I use to annotate lot areas; I revised it to create a region. Hopefully you can use parts of the code for your use. ;Labels a lot's area using the Boundary command. LPS 2008-10 (defun c:LA () ;(/ cl txtst txtsz oldecho oldsnap B ac sf kw) (setq temperr *error*);store *error* (setq *error* errortrap);reassign *error* (setq cl (getvar "clayer") txtst (getvar "textstyle") txtsz (getvar "textsize") oldecho (getvar "cmdecho") oldsnap (getvar "osmode") );setq (setvar "cmdecho" 0) (command "-style" "SIMPLEX" "simplex.shx" "0" "0.9" "0" "n" "n" "n") (setq ip (getpoint "\nPick internal point: ")) (command "-layer" "m" "calc" "c" "63" "calc" "p" "n" "calc" "") (command "-boundary" ip "") (command "region" (entlast) "") (setq b (entlast)) (command "area" "o" b) (setq ac (strcat (rtos (/ (getvar "area") 43560) 2 3) " ACRES")) (setq sf (strcat (rtos (getvar "area") 2 2) " SQ.FT.")) (command "-layer" "m" "LOT-AREA" "c" "53" "" "") (command "text" "s" "simplex" "c" ip (* 0.12 (getvar "dimscale")) "0" sf ) (command "text" "" ac) (initget "Yes No") (setq kw (getkword "\nErase boundary Yes/No? <Yes>")) (if (= kw nil) (command "erase" b "") ) ;if (command "textstyle" txtst) (setvar "clayer" cl) (setvar "textsize" txtsz) (setvar "cmdecho" oldecho) (setvar "osmode" oldsnap) (setq *error* temperr) (princ) );defun c: ;==========ERROR TRAP================= (defun errortrap (msg) ;define function (setvar "textstyle" txtst) (setvar "textsize" txtsz) (setvar "clayer" cl) (setvar "cmdecho" oldecho) ;restore variables (setvar "osmode" oldsnap) (setq *error* temperr) ;restore *error* (prompt "\nResetting System Variables ") ;inform user (princ) );defun ;==========ERROR TRAP================= (prompt "\nLotArea.lsp loaded, type LA to run") (princ) Quote Link to comment Share on other sites More sharing options...
arulmozhi Posted November 9, 2008 Author Share Posted November 9, 2008 Thank you. It works pretty well. Still I need some more help to fulfil my task. Please change the code to give areas in square meteres with 3 decimal places. Further I need to make a table in Excel using different parts of the drawing. Therefore please make some code to put the areas in specified cells of mentioned excel sheets. Quote Link to comment Share on other sites More sharing options...
lpseifert Posted November 10, 2008 Share Posted November 10, 2008 Hint: Look in Developer's Help for (rtos... real to string (open... open or create file. make it a .csv for excel (write-line... write lines to the open file Quote Link to comment Share on other sites More sharing options...
arulmozhi Posted November 11, 2008 Author Share Posted November 11, 2008 I'll try it and come back. Quote Link to comment Share on other sites More sharing options...
metricscale Posted November 12, 2008 Share Posted November 12, 2008 i'm a begginner at lisp and i need a drafting of rodway cross section program, can anybody please help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.