s8utt Posted March 18, 2010 Posted March 18, 2010 Hello I've got an autocad scr file which draws a polyline I can use the following command to return the area of the polyline area o 0,60 this gives me Area = 177529.36, Perimeter = 2510.37 is there anyway to take these figures and add them as text to the drawing ? Or is there any command I ca use to find out the objectid for the polyline so I can use %%).Area \f "%lu2">% Quote
alanjt Posted March 18, 2010 Posted March 18, 2010 Tested once... (defun c:PLabel (/ #Obj #Pnt #Id) (vl-load-com) (and (setq #Obj (car (entsel "\nSelect LWPolyline: "))) (or (eq "LWPOLYLINE" (cdr (assoc 0 (entget #Obj)))) (alert "Invalid object!") ) ;_ or (setq #Pnt (getpoint "\nSpecify MText placement point: ")) (setq #Id (itoa (vla-get-objectid (vlax-ename->vla-object #Obj)))) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(71 . 5) (cons 7 (getvar 'textstyle)) (cons 10 #Pnt) (cons 1 (strcat "Area: %<\\AcObjProp Object(%<\\_ObjId " #Id ">%).Area \\f \"%lu2\">%\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId " #Id " >%).Length \\f \"%lu2\">%" ) ;_ strcat ) ;_ cons ) ;_ list ) ;_ entmakex ) ;_ and (princ) ) ;_ defun Quote
s8utt Posted March 18, 2010 Author Posted March 18, 2010 erm, thanks but how do I use this in a scr file ? Quote
Lee Mac Posted March 18, 2010 Posted March 18, 2010 Hi, Try this: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:GetAreas [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* lst->str DOC IDS PT SS UFLAG[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [i][color=#990099];; Lee Mac ~ 18.03.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] lst->str [b][color=RED]([/color][/b]lst d1 d2[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b] d2 [b][color=RED]([/color][/b]lst->str [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] d1 d2[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ARC,CIRCLE,ELLIPE,HATCH,*POLYLINE,REGION"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#a52a2a]"\nPick Point for Field: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] obj [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSelectionSet[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Ids [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ObjectId[/color][/b] obj[b][color=RED])[/color][/b][b][color=RED])[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b] ss[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-AddMText[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=Blue]AcModelSpace [/color][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=Blue]:vlax-true [/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-MSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ModelSpace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-PaperSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009999]0.[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"%<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Ids[b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"%<\\AcExpr"[/color][/b] [b][color=RED]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Area >% +"[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area >% \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote
s8utt Posted March 18, 2010 Author Posted March 18, 2010 thanks also, could you tell me how I am to use the above code to get the result I'm after. kinda new to AutoCad. Thanks Quote
Lee Mac Posted March 18, 2010 Posted March 18, 2010 Perhaps take a look here: http://www.cadtutor.net/forum/showthread.php?t=1390 Quote
stevesfr Posted March 18, 2010 Posted March 18, 2010 Tested once... (defun c:PLabel (/ #Obj #Pnt #Id) (vl-load-com) (and (setq #Obj (car (entsel "\nSelect LWPolyline: "))) (or (eq "LWPOLYLINE" (cdr (assoc 0 (entget #Obj)))) (alert "Invalid object!") ) ;_ or (setq #Pnt (getpoint "\nSpecify MText placement point: ")) (setq #Id (itoa (vla-get-objectid (vlax-ename->vla-object #Obj)))) (entmakex (list '(0 . "MTEXT") '(100 . "AcDbEntity") '(100 . "AcDbMText") '(71 . 5) (cons 7 (getvar 'textstyle)) (cons 10 #Pnt) (cons 1 (strcat "Area: %<\\AcObjProp Object(%<\\_ObjId " #Id ">%).Area \\f \"%lu2\">%\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId " #Id " >%).Length \\f \"%lu2\">%" ) ;_ strcat ) ;_ cons ) ;_ list ) ;_ entmakex ) ;_ and (princ) ) ;_ defun well, that backfired !!! Quote
Lee Mac Posted March 18, 2010 Posted March 18, 2010 Yeah, you can't create a field that easily using entmake as the FIELD object is stored within the TEXT Dictionary which is stored in the ACAD_FIELD dictionary which is itself stored in the extension dictionary of the text, mtext or attribute (whichever you are creating). So to use entmake you have to entmake these dictionaries in the mtext extension dictionary. Lee Quote
Lee Mac Posted March 18, 2010 Posted March 18, 2010 Another variant for Areas and Perimeters [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:GetAP [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* lst->str DOC IDS PT SS UFLAG[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [i][color=#990099];; Lee Mac ~ 18.03.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] lst->str [b][color=RED]([/color][/b]lst d1 d2[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b] d2 [b][color=RED]([/color][/b]lst->str [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] d1 d2[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#a52a2a]"\nSelect Objects to Retrieve Total Area + Perimeter..."[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ARC,CIRCLE,ELLIPE,HATCH,*POLYLINE,REGION"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#a52a2a]"\nPick Point for Field: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] obj [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSelectionSet[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Ids [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ObjectId[/color][/b] obj[b][color=RED])[/color][/b][b][color=RED])[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b] ss[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-AddMText[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=Blue]AcModelSpace [/color][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=Blue]:vlax-true[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-MSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ModelSpace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-PaperSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009999]0.[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Ids[b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Ids[b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Length \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcExpr"[/color][/b] [b][color=RED]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Area >% +"[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area >% \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcExpr"[/color][/b] [b][color=RED]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Length >% +"[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Length >% \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote
alanjt Posted March 18, 2010 Posted March 18, 2010 Yeah, you can't create a field that easily using entmake as the FIELD object is stored within the TEXT Dictionary which is stored in the ACAD_FIELD dictionary which is itself stored in the extension dictionary of the text, mtext or attribute (whichever you are creating). So to use entmake you have to entmake these dictionaries in the mtext extension dictionary. Lee well, that backfired !!! Yeah, I wasn't thinking about that. It places the field, but you have to edit the text once. Not sure why I even used entmake in the first place. Just for the sake of it working properly... (defun c:PLabel (/ #Obj #Pnt #Id) (vl-load-com) (and (setq #Obj (car (entsel "\nSelect LWPolyline: "))) (or (eq "LWPOLYLINE" (cdr (assoc 0 (entget #Obj)))) (alert "Invalid object!") ) ;_ or (setq #Pnt (getpoint "\nSpecify MText placement point: ")) (setq #Id (itoa (vla-get-objectid (vlax-ename->vla-object #Obj)))) (AT:MText #Pnt (strcat "Area: %<\\AcObjProp Object(%<\\_ObjId " #Id ">%).Area \\f \"%lu2\">%\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId " #Id " >%).Length \\f \"%lu2\">%" ) ;_ strcat 0 nil 5 ) ;_ AT:MText ) ;_ and (princ) ) ;_ defun ;;; Add MText to drawing ;;; #InsertionPoint - MText insertion point ;;; #String - String to place in created MText object ;;; #Width - Width of MText object (if nil, will be 0 width) ;;; #Layer - Layer to place Mtext object on (nil for current) ;;; #Justification - Justification # for Mtext object ;;; 1 or nil= TopLeft ;;; 2= TopCenter ;;; 3= TopRight ;;; 4= MiddleLeft ;;; 5= MiddleCenter ;;; 6= MiddleRight ;;; 7= BottomLeft ;;; 8= BottomCenter ;;; 9= BottomRight ;;; Alan J. Thompson, 05.23.09 (defun AT:MText (#InsertionPoint #String #Width #Layer #Justification / #Width #Space #Insertion #Object ) (or #Width (setq #Width 0)) (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))) ) ;_ or (setq #Space (if (or (eq acmodelspace (vla-get-activespace *AcadDoc*) ) ;_ eq (eq :vlax-true (vla-get-mspace *AcadDoc*)) ) ;_ or (vla-get-modelspace *AcadDoc*) (vla-get-paperspace *AcadDoc*) ) ;_ if #Insertion (cond ((vl-consp #InsertionPoint) (vlax-3d-point #InsertionPoint)) ((eq (type #InsertionPoint) 'variant) #InsertionPoint) (T nil) ) ;_ cond ) ;_ setq ;; create MText object (setq #Object (vla-addmtext #Space #Insertion #Width #String)) ;; change layer, if applicable (and #Layer (tblsearch "layer" #Layer) (vla-put-layer #Object #Layer) ) ;_ and ;; change justification & match insertion point with new justification (cond ((member #Justification (list 1 2 3 4 5 6 7 8 9)) (vla-put-attachmentpoint #Object #Justification) (vla-move #Object (vla-get-InsertionPoint #Object) #Insertion ) ;_ vla-move ) ) ;_ cond #Object ) ;_ defun Quote
s8utt Posted March 19, 2010 Author Posted March 19, 2010 greetings, thanks for all your assitance. am I doing something wrong ? I created the file, rang it and it sucessfully created the text. However instead of figures its giving #### do I need to perform something in addition ? Also ( using GetAP script ) why is the area in normal text but the #### has a grey background ? many thanks for all your help Quote
s8utt Posted March 19, 2010 Author Posted March 19, 2010 update looking at the ####, if I double click on it it brings up the fields dialog and 'unknown' is shown. The field expression is shown as %%).Area \f "%lu2">% If I manually click on field name: object > property area the field expression is shown as %%).Area \f "%lu2">% looks like the objetc id's are different ? Quote
Lee Mac Posted March 19, 2010 Posted March 19, 2010 Using my GetAP function, all seems fine. I'm not sure why you are getting an incorrect ObjectID The grey background indicates that the text is a field. Quote
s8utt Posted March 19, 2010 Author Posted March 19, 2010 If I change part your code slightly to this (strcat "Area:(%<\\_ObjId " (car Ids) ">%) %<\\AcObjProp Object(%<\\_ObjId 8796087810544>%).Area \\f \"%lu6%qf1\">%" "\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId " (car Ids) ">%).Length \\f \"%lu6\">%") so I've added objectid into area string I've hard coded my current objectid I get Area:(42) 57390.52 so hardcoding the objectid worked so that part is good. whats strange for me is the object id changes everytime you run autocad right ? so my object id has changed from that one above. the 42 hasn't changed though ?? is there a really simple command I can run to return the objectid of selected objectd as I think this is where I'm having the problems. thanks Quote
s8utt Posted March 19, 2010 Author Posted March 19, 2010 ohhh just thought, maybe the problem is this using windows 7 64 bit autocad 2009 64 bit ? Quote
s8utt Posted March 19, 2010 Author Posted March 19, 2010 update, definately a problem due to 64bit autocad. found this snippet ;; function to get the ID string from a object ; (Get-ObjectIDx64 (car (entsel))) (defun Get-ObjectIDx64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0) ) ) ) this returns the correct objectid, now now to implement it into the code. any suggestions ? Quote
Lee Mac Posted March 19, 2010 Posted March 19, 2010 Wow, I didn't realise there was that much of a difference... anyway, here is my updated code: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:GetAP [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* lst->str DOC IDS PT SS UFLAG UTIL[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [i][color=#990099];; Lee Mac ~ 18.03.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] lst->str [b][color=RED]([/color][/b]lst d1 d2[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b] d2 [b][color=RED]([/color][/b]lst->str [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] d1 d2[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] GetObjectID [b][color=RED]([/color][/b]obj[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] util [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b]util[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]vla-get-Utility[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-string-search[/color][/b] [b][color=#a52a2a]"X64"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=DARKRED]'[/color][/b]PLATFORM[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke-method[/color][/b] util [b][color=DARKRED]'[/color][/b]GetObjectIdString obj [b][color=Blue]:vlax-false[/color][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Objectid[/color][/b] obj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#a52a2a]"\nSelect Objects to Retrieve Total Area + Perimeter..."[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ARC,CIRCLE,ELLIPE,HATCH,*POLYLINE,REGION"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#a52a2a]"\nPick Point for Field: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] obj [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSelectionSet[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Ids [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b]GetObjectID Obj[b][color=RED])[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b] ss[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-AddMText[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=Blue]AcModelSpace [/color][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [color=Blue][b]:vlax-true[/b][/color] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-MSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ModelSpace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-PaperSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009999]0.[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Ids[b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Ids[b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Length \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcExpr"[/color][/b] [b][color=RED]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Area >% +"[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area >% \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcExpr"[/color][/b] [b][color=RED]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Length >% +"[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Length >% \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] Quote
stevesfr Posted March 19, 2010 Posted March 19, 2010 Wow, I didn't realise there was that much of a difference... anyway, here is my updated code: [b][color=red]([/color][/b][b][color=blue]defun[/color][/b] c:GetAP [b][color=red]([/color][/b][b][color=blue]/[/color][/b] *error* lst->str DOC IDS PT SS UFLAG UTIL[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vl-load-com[/color][/b][b][color=red])[/color][/b] [i][color=#990099];; Lee Mac ~ 18.03.10[/color][/i] [b][color=red]([/color][/b][b][color=blue]defun[/color][/b] *error* [b][color=red]([/color][/b]msg[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]and[/color][/b] uFlag [b][color=red]([/color][/b][b][color=blue]vla-EndUndomark[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]or[/color][/b] [b][color=red]([/color][/b][b][color=blue]wcmatch[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcase[/color][/b] msg[b][color=red])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]princ[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]princ[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]defun[/color][/b] lst->str [b][color=red]([/color][/b]lst d1 d2[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]cdr[/color][/b] lst[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcat[/color][/b] d1 [b][color=red]([/color][/b][b][color=blue]car[/color][/b] lst[b][color=red])[/color][/b] d2 [b][color=red]([/color][/b]lst->str [b][color=red]([/color][/b][b][color=blue]cdr[/color][/b] lst[b][color=red])[/color][/b] d1 d2[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcat[/color][/b] d1 [b][color=red]([/color][/b][b][color=blue]car[/color][/b] lst[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]defun[/color][/b] GetObjectID [b][color=red]([/color][/b]obj[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] util [b][color=red]([/color][/b][b][color=blue]cond[/color][/b] [b][color=red]([/color][/b]util[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=red]([/color][/b][b][color=blue]vla-get-Utility[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-get-ActiveDocument[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-get-acad-object[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]vl-string-search[/color][/b] [b][color=#a52a2a]"X64"[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcase[/color][/b] [b][color=red]([/color][/b][b][color=blue]getvar[/color][/b] [b][color=darkred]'[/color][/b]PLATFORM[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-invoke-method[/color][/b] util [b][color=darkred]'[/color][/b]GetObjectIdString obj [b][color=blue]:vlax-false[/color][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]itoa[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-get-Objectid[/color][/b] obj[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]princ[/color][/b] [b][color=#a52a2a]"\nSelect Objects to Retrieve Total Area + Perimeter..."[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]and[/color][/b] [b][color=red]([/color][/b][b][color=blue]ssget[/color][/b] [b][color=darkred]'[/color][/b][b][color=red]([/color][/b][b][color=red]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"ARC,CIRCLE,ELLIPE,HATCH,*POLYLINE,REGION"[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] pt [b][color=red]([/color][/b][b][color=blue]getpoint[/color][/b] [b][color=#a52a2a]"\nPick Point for Field: "[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]progn[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] uFlag [b][color=red]([/color][/b][b][color=blue]not[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-StartUndoMark[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] doc [b][color=red]([/color][/b][b][color=blue]vla-get-ActiveDocument[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-get-acad-object[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-for[/color][/b] obj [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] ss [b][color=red]([/color][/b][b][color=blue]vla-get-ActiveSelectionSet[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] Ids [b][color=red]([/color][/b][b][color=blue]cons[/color][/b] [b][color=red]([/color][/b]GetObjectID Obj[b][color=red])[/color][/b] Ids[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-delete[/color][/b] ss[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-AddMText[/color][/b] [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]or[/color][/b] [b][color=red]([/color][/b][b][color=blue]eq[/color][/b] [b][color=blue]AcModelSpace [/color][color=red]([/color][/b][b][color=blue]vla-get-ActiveSpace[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]eq[/color][/b] [color=blue][b]:vlax-true[/b][/color] [b][color=red]([/color][/b][b][color=blue]vla-get-MSpace[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-get-ModelSpace[/color][/b] doc[b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vla-get-PaperSpace[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]vlax-3D-point[/color][/b] pt[b][color=red])[/color][/b] [b][color=#009999]0.[/color][/b] [b][color=red]([/color][/b][b][color=blue]if[/color][/b] [b][color=red]([/color][/b][b][color=blue]=[/color][/b] [b][color=#009900]1[/color][/b] [b][color=red]([/color][/b][b][color=blue]length[/color][/b] Ids[b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=red]([/color][/b][b][color=blue]car[/color][/b] Ids[b][color=red])[/color][/b] [b][color=#a52a2a]">%).Area \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=red]([/color][/b][b][color=blue]car[/color][/b] Ids[b][color=red])[/color][/b] [b][color=#a52a2a]">%).Length \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcExpr"[/color][/b] [b][color=red]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Area >% +"[/color][/b][b][color=red])[/color][/b] [b][color=#a52a2a]">%).Area >% \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcExpr"[/color][/b] [b][color=red]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Length >% +"[/color][/b][b][color=red])[/color][/b] [b][color=#a52a2a]">%).Length >% \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]setq[/color][/b] uFlag [b][color=red]([/color][/b][b][color=blue]vla-EndUndomark[/color][/b] doc[b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] [b][color=red]([/color][/b][b][color=blue]princ[/color][/b][b][color=red])[/color][/b][b][color=red])[/color][/b] well my friend, unless I've got something set wierd, it won't cough up perimeter (cir) of a circular region? S Quote
Lee Mac Posted March 19, 2010 Posted March 19, 2010 Oh yes, I added the Perimeter output, but should have removed the Circle etc from the Selset: [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] c:GetAP [b][color=RED]([/color][/b][b][color=BLUE]/[/color][/b] *error* lst->str DOC IDS PT SS UFLAG UTIL[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-load-com[/color][/b][b][color=RED])[/color][/b] [i][color=#990099];; Lee Mac ~ 18.03.10[/color][/i] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] *error* [b][color=RED]([/color][/b]msg[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]wcmatch[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] msg[b][color=RED])[/color][/b] [b][color=#a52a2a]"*BREAK,*CANCEL*,*EXIT*"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"\n** Error: "[/color][/b] msg [b][color=#a52a2a]" **"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] lst->str [b][color=RED]([/color][/b]lst d1 d2[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b] d2 [b][color=RED]([/color][/b]lst->str [b][color=RED]([/color][/b][b][color=BLUE]cdr[/color][/b] lst[b][color=RED])[/color][/b] d1 d2[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] d1 [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] lst[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]defun[/color][/b] GetObjectID [b][color=RED]([/color][/b]obj[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] util [b][color=RED]([/color][/b][b][color=BLUE]cond[/color][/b] [b][color=RED]([/color][/b]util[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=BLUE]vla-get-Utility[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vl-string-search[/color][/b] [b][color=#a52a2a]"X64"[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcase[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]getvar[/color][/b] [b][color=DARKRED]'[/color][/b]PLATFORM[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-invoke-method[/color][/b] util [b][color=DARKRED]'[/color][/b]GetObjectIdString obj [b][color=Blue]:vlax-false[/color][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]itoa[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-Objectid[/color][/b] obj[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b] [b][color=#a52a2a]"\nSelect Objects to Retrieve Total Area + Perimeter..."[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]and[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]ssget[/color][/b] [b][color=DARKRED]'[/color][/b][b][color=RED]([/color][/b][b][color=RED]([/color][/b][b][color=#009900]0[/color][/b] . [b][color=#a52a2a]"LINE,*POLYLINE"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] pt [b][color=RED]([/color][/b][b][color=BLUE]getpoint[/color][/b] [b][color=#a52a2a]"\nPick Point for Field: "[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]progn[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]not[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-StartUndoMark[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] doc [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveDocument[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-get-acad-object[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-for[/color][/b] obj [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] ss [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSelectionSet[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] Ids [b][color=RED]([/color][/b][b][color=BLUE]cons[/color][/b] [b][color=RED]([/color][/b]GetObjectID Obj[b][color=RED])[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-delete[/color][/b] ss[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-AddMText[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]or[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [b][color=Blue]AcModelSpace [/color][color=RED]([/color][/b][b][color=BLUE]vla-get-ActiveSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]eq[/color][/b] [color=Blue][b]:vlax-true[/b][/color] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-MSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-ModelSpace[/color][/b] doc[b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vla-get-PaperSpace[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]vlax-3D-point[/color][/b] pt[b][color=RED])[/color][/b] [b][color=#009999]0.[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]if[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]=[/color][/b] [b][color=#009900]1[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]length[/color][/b] Ids[b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Ids[b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]car[/color][/b] Ids[b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Length \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]strcat[/color][/b] [b][color=#a52a2a]"Area: %<\\AcExpr"[/color][/b] [b][color=RED]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Area >% +"[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Area >% \\f \"[/color][color=#a52a2a]%lu6%qf1\[/color][/b][b][color=#a52a2a]">%"[/color][/b] [b][color=#a52a2a]"\\PPerimeter: %<\\AcExpr"[/color][/b] [b][color=RED]([/color][/b]lst->str Ids [b][color=#a52a2a]" %<\\AcObjProp Object(%<\\_ObjId "[/color][/b] [b][color=#a52a2a]">%).Length >% +"[/color][/b][b][color=RED])[/color][/b] [b][color=#a52a2a]">%).Length >% \\f \"[/color][color=#a52a2a]%lu6\[/color][/b][b][color=#a52a2a]">%"[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]setq[/color][/b] uFlag [b][color=RED]([/color][/b][b][color=BLUE]vla-EndUndomark[/color][/b] doc[b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b][b][color=RED])[/color][/b] [b][color=RED]([/color][/b][b][color=BLUE]princ[/color][/b][b][color=RED])[/color][/b][b][color=RED]) [/color][/b] 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.