Lee Mac Posted May 30, 2010 Posted May 30, 2010 Making my (line or spline combined with polyline shapes) into a polyline and getting an area with list or properties was how this whole thing started. I wanted to avoid having to join my random stuff into a polyline and wondered if I could simply select the variety of things (in the case of the example sent, an arc and three lines) that make up the perimeter and use some command to get an area. Perhaps look into creating a boundary using an interior point or otherwise, and then you can see the area of the boundary. As for the LISP, here are a few from my link archive... Starting LISP: http://www.afralisp.net/ http://www.jefferypsanders.com/autolisptut.html http://ronleigh.info/autolisp/index.htm More Advanced LISP Tutorials/Help: http://augiru.augi.com/content/library/au07/data/paper/CP311-4.pdf http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-4.html http://www.cs.cmu.edu/afs/cs.cmu.edu/project/ai-repository/ai/html/cltl/clm/node1.html Quote
Lee Mac Posted May 30, 2010 Posted May 30, 2010 Just thought I may have missed your point - if you are having trouble running the LISP codes I linked you to, click on the link in my signature. Quote
eldon Posted May 30, 2010 Posted May 30, 2010 Have you tried BPOLY? I haven't seen mention of it yet, but my glasses might be a bit smudged. Quote
Lee Mac Posted May 30, 2010 Posted May 30, 2010 A quick shot at a LISP using the boundary command: (defun c:ga ( / *error* CM LastEntity pt spc ) (vl-load-com) ;; © Lee Mac ~ 30.05.10 (defun *error* ( msg ) (and CM (setvar 'CMDECHO CM)) (and ent (entdel ent)) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (setq spc (if (or (eq AcModelSpace (vla-get-ActiveSpace (setq doc (vla-get-ActiveDocument (vlax-get-acad-object) ) ) ) ) (eq :vlax-true (vla-get-MSpace doc)) ) (vla-get-ModelSpace doc) (vla-get-PaperSpace doc) ) ) (setq CM (getvar 'CMDECHO)) (setvar 'CMDECHO 0) (while (progn (setq LastEntity (entlast)) (if (setq pt (getpoint "\nPick Internal Point to Retrieve Area: ")) (progn (vl-cmdf "_.-boundary" "_A" "_O" "_P" "" pt "") (if (not (equal LastEntity (setq ent (entlast)))) (progn (PlaceText spc (rtos (vla-get-Area (vlax-ename->vla-object ent) ) ) "\nPlace Area Text: " ) (entdel ent) (setq ent nil) t ) (princ "\n** Not A Valid Boundary **") ) ) ) ) ) (setvar 'CMDECHO CM) (princ) ) (defun PlaceText ( Block TextStr PromptStr / pt ent tables ) (setq tables (ss->vla (ssget "_X" '((0 . "ACAD_TABLE"))))) (if (setq pt (getpoint PromptStr)) (cond ( (TextinCell tables pt TextStr) ) ( (and (setq ent (nentselp pt)) (= 2 (length ent)) (wcmatch (cdr (assoc 0 (entget (setq ent (car ent)) ) ) ) "TEXT,MTEXT,ATTRIB" ) ) (vla-put-TextString (vlax-ename->vla-object ent) TextStr ) ) ( (vla-AddMText Block (vlax-3D-point (trans pt 1 0)) 0 TextStr ) ) ) ) ) (defun TextinCell ( tables pt str / data ) ;; © Lee Mac ~ 17.05.10 (if (setq data (vl-some (function (lambda ( table ) (if (eq :vlax-true (vla-hittest table (vlax-3D-point (trans pt 1 0)) (vlax-3D-point (trans (getvar 'VIEWDIR) 1 0)) 'row 'col ) ) (list table row col) ) ) ) tables ) ) (not (apply (function vla-setText) (append data (list str)) ) ) ) ) (defun ss->vla ( ss ) (if ss ( (lambda ( i / e l ) (while (setq e (ssname ss (setq i (1+ i)))) (setq l (cons (vlax-ename->vla-object e) l)) ) l ) -1 ) ) ) Will place result as MText in drawing or within attribute or table. Quote
td88 Posted May 30, 2010 Author Posted May 30, 2010 Just thought I may have missed your point - if you are having trouble running the LISP codes I linked you to, click on the link in my signature. You didn't miss my point for long, Lee Mac. The link in your signature was precisely what I was asking for with regard to lisp. I'm assuming the instructional links you sent in the prior post will, also, be greatly helpful, when I proceed to actually writing lisp. For now, how to load and use your stuff gets me somewhere I want to be. If there's any similar instructional stuff on macro's, CUI and their use, I'm interested. Thank you, Lee Mac Quote
Lee Mac Posted May 30, 2010 Posted May 30, 2010 You're very welcome Looking at your last post regarding having a lot of random stuff that you don't want to have to connect up into a polyline - my last code posting in this thread may be the most use to you. The others I linked you to previously would use closed polylines and display the area/perimeter in a FIELD. I'm glad you found what you were looking for, and I'm sure those earlier links will help too if you decide to dabble in LISP. As for Macro's and the CUI there isn't too much you really need to know if you have some knowledge of standard AutoCAD commands. As far as Macros go, they will execute a list of AutoCAD commands as if the user were entering them into the command line manually, with a few keywords such that a semi-colon or space will emulate the user pressing 'enter' and a backslash "\" will mean that the macro will pause for user input before proceeding to execute the remaining string. Example, drawing a line from 0,0,0 to a user defined point: [color=Red][b]^C^C[/b][/color][color=Green][b]_.[/b][/color][color=Blue][b]line[/b][/color][b][color=Red];[/color][/b][b][color=Blue]0,0,0[/color][color=Red];[/color][/b][b][color=Purple]\[/color][color=Red];[/color][/b] The ^C^C will emulate the user pressing Esc twice, and hence cancelling any active commands before invoking the line command. The "_." are standard AutoCAD command prefixes, more about them can be found here. You can also use DIESEL in Macro strings (and LISP), this can be quite handy. A DIESEL reference may be found here, along with a few examples. Hope this helps, and if you have any questions, just ask. Lee Quote
td88 Posted May 30, 2010 Author Posted May 30, 2010 Have you tried BPOLY? I haven't seen mention of it yet, but my glasses might be a bit smudged. Thank you, eldon. I tried bpoly and it seemed quite useful. It created a polyline from entities (although it took around 30 sec.'s for it to analyze the attached object). I didn't understand a lot of the terms in the dialog box and tried to look them up in the Help/Index and could not get a hit on the term bpoly, although, when I entered bpoly on the command line, it functioned. Does it have a longer name that Help/Index will understand? Quote
Lee Mac Posted May 30, 2010 Posted May 30, 2010 My code above uses the BOUNDARY command with the ObjectType set to Polyline, I could be wrong, but I believe this is the same as BPOLY. Quote
eldon Posted May 30, 2010 Posted May 30, 2010 Does it have a longer name that Help/Index will understand? Perhaps Boundary Polyline Quote
td88 Posted May 30, 2010 Author Posted May 30, 2010 My code above uses the BOUNDARY command with the ObjectType set to Polyline, I could be wrong, but I believe this is the same as BPOLY. Boundary it is, Lee Mac. You are becoming one stop shopping for me. Thank you Quote
td88 Posted May 30, 2010 Author Posted May 30, 2010 Perhaps Boundary Polyline Thank you, eldon. Boundary is working. Quote
Lee Mac Posted May 30, 2010 Posted May 30, 2010 You're welcome Tim, happy I could help Bear in mind with my code, although the cursor has the 'point picking' crosshairs, if you click on an attribute or within a table cell, the result will be place directly into such. Quote
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.