cooperd Posted October 30, 2009 Posted October 30, 2009 Hey guys, Is there a way I could easily get the length of the polyline into a variable in this code? What I would like to is determine if the length is between certain values using if statements then edit the label to indicate whether the length is less than or greater than a certain threshold. Any thoughts? Thanks, Dave Quote
alanjt Posted October 30, 2009 Posted October 30, 2009 Hey guys, Is there a way I could easily get the length of the polyline into a variable in this code? What I would like to is determine if the length is between certain values using if statements then edit the label to indicate whether the length is less than or greater than a certain threshold. Any thoughts? Thanks, Dave This should help you with the answers you need... (defun c:Test (/ o) (and (setq o (car (entsel "\nSelect LWPolyline: "))) ; select (setq o (vlax-ename->vla-object o)) ; convert to vla-object (eq (vla-get-objectname o) "AcDbPolyline") ; verify object type (alert (strcat "Area: " (vl-princ-to-string (vla-get-area o)) ; get area "\nLength: " (vl-princ-to-string (vla-get-length o)) ; get length ) ;_ strcat ) ;_ alert ) ;_ and (princ) ) ;_ defun Quote
cooperd Posted October 30, 2009 Posted October 30, 2009 Thanks a lot Alan, I combined Fixos script with yours and it is working well. Quote
alanjt Posted October 30, 2009 Posted October 30, 2009 Thanks a lot Alan, I combined Fixos script with yours and it is working well. Glad you got it to work. Quote
BetaCAD Posted September 2, 2016 Posted September 2, 2016 Hello. I've been using a customized version of this lisp for a long time with Autocad 2011. Now I have passed to R2013 and I get this error message: ; warning:AutoCAD type library load failed: "Error during the upload of the DLL library" ; error: no function definition: VLAX-GET-ACAD-OBJECT I know this is a common problem for that function but I haven't found the solution. So, I'd like to know if someone can tell me how to fix it or if someone can update my lisp that I paste here below. Many thanks in advance. (defun c:fa (/ acsp adoc cpt elist en ent fld lead_obj lpt mtx oid osm) (vl-load-com) (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object) ) ) ) (if (and (= (getvar "tilemode") 0) (= (getvar "cvport") 1) ) (setq acsp (vla-get-paperspace adoc)) (setq acsp (vla-get-modelspace adoc)) ) (setq osm (getvar "osmode")) (setvar "osmode" 0) (while (setq ent (entsel "\nSelect pline or hit Enter to exit")) (setq en (car ent)) (if (wcmatch (cdr (assoc 0 (setq elist (entget en)))) "*POLYLINE") (progn (setq cpt (trans (cadr ent) 1 0) lpt (trans (getpoint cpt "\nPick the ending point of leader:") 1 0) ) (setq oid (vla-get-objectid (vlax-ename->vla-object en))) (setq fld (strcat (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa oid) ">%).Area \\f \"%lu2%pr2%ps[Mq. ,]%ds44%ct8[0.0001]\">%" "\\P")) ) (setq mtx (vlax-invoke acsp 'addmtext lpt 0.0 fld) ) (vlax-put mtx 'attachmentpoint (cond ((> (car cpt) (car lpt)) 6 ) ((< (car cpt) (car lpt)) 4 ) (t 4) ) ) (vlax-put mtx 'height (getvar "textsize")) (setq lead_obj (vlax-invoke acsp 'addleader (apply 'append (list cpt lpt)) mtx aclinewitharrow ) ) (vlax-put lead_obj 'verticaltextposition 0) ;1 ) ) ) (setvar "osmode" osm) (princ) ) (princ "\n Start command with FA ...") (princ) Quote
mjavy7 Posted April 5, 2018 Posted April 5, 2018 Give this a try (defun C:FA (/ acsp adoc cpt elist en ent fld lead_obj lpt mtx oid osm) (vl-load-com) (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object) ) ) ) (if (and (= (getvar "tilemode") 0) (= (getvar "cvport") 1) ) (setq acsp (vla-get-paperspace adoc)) (setq acsp (vla-get-modelspace adoc)) ) (setq osm (getvar "osmode")) (setvar "osmode" 0) (while (setq ent (entsel "\nSelect pline or hit Enter to exit")) (setq en (car ent)) (if (wcmatch (cdr (assoc 0 (setq elist (entget en)))) "*POLYLINE") (progn (setq cpt (trans (cadr ent)1 0) lpt (trans (getpoint cpt "\nPick the ending point of leader:") 1 0) ) (setq oID (vla-get-objectid (vlax-ename->vla-object en))) (setq fld (strcat (strcat "Area = " "%<\\AcObjProp Object(%<\\_ObjId " (itoa oID) ">%).Area \\f \"%lu2%pr2\">%" "\\P")) (setq mtx (vlax-invoke acsp 'AddMText lpt 0.0 fld) ) (vlax-put mtx 'AttachmentPoint (cond ((> (car cpt) (car lpt)) 6 ) ((< (car cpt) (car lpt)) 4 ) (T 4) ) ) (vlax-put mtx 'Height (getvar "textsize")) (setq lead_obj (vlax-invoke acsp 'Addleader (apply 'append (list cpt lpt)) mtx acLineWithArrow ) ) (vlax-put lead_obj 'VerticalTextPosition 0);1 ) ) ) (setvar "osmode" osm) (princ) ) (princ "\n Start command with FA ...") (princ) Can this multiply the area by a factor (i.e. 3.62) and return that answer instead? I am not worried about units at this point. Also the can the precision be set to match the current dimension style in use? or just set to round to then whole number w/o decimals? thanks for the help! 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.