ebrito Posted January 19, 2009 Posted January 19, 2009 I am trying to write a code to extract the dimscale of an existing dimension by picking it. I have tried using "assoc" without any results. Any help will be welcomed Quote
CAB Posted January 19, 2009 Posted January 19, 2009 Give this a shot. (defun c:dsf (/ ent obj) (vl-load-com) (and (or (setq ent (entsel "\nSelect dimension to get Scale Factor.")) (prompt "\nNothing selected.")) (setq obj (vlax-ename->vla-object (car ent))) (or (vlax-property-available-p obj 'ScaleFactor) (prompt "\nNo scale factor.")) (print) (princ (vla-get-ScaleFactor obj)) ) (princ) ) Quote
ebrito Posted January 19, 2009 Author Posted January 19, 2009 Thanks But I get this message after loading "error: extra right paren on input" I tried to fix it without success. Quote
Lee Mac Posted January 19, 2009 Posted January 19, 2009 The code should work as is - I have just tested it. The error that you are encountering means there is an extra ")" - possibly one that you have accidentally typed? Quote
CarlB Posted January 19, 2009 Posted January 19, 2009 ...or missed the very first "(" when copying... Quote
Lee Mac Posted January 19, 2009 Posted January 19, 2009 ...or missed the very first "(" when copying... Yes, or that Quote
ebrito Posted January 20, 2009 Author Posted January 20, 2009 You are right I missed the first "(" whwn copying. Thanks a lot. I modify your code to select a dimension "dimscale" and "layer" to have a lisp to place continued dimensions in the selected layer and dimscale, using the selected dimension as a base. I tried several command combinations without successes. I am new to lisp and all help is welcomed (defun c:dlcon (/ ent obj) (vl-load-com) (and (or (setq ent (entsel "\nSelect Base Dimension")) (prompt "\nNothing Selected")) (setq obj (vlax-ename->vla-object (car ent))) (or (vlax-property-available-p obj 'ScaleFactor) (prompt "\nNo scale factor.")) (print) ;(princ (vla-get-ScaleFactor obj)) ) (setq a (vla-get-ScaleFactor obj)) (setvar "dimscale" a) (setq X (cdr (assoc 8 (entget (car ent))))) (command ".layer" "set" X "") ;In this section I want to have a command to place continued dimensions ;in the selected layer and dimscale, using the selected dimension as a base. ;I tried several command combinations without successs. (COMMAND "LAYER" "SET" "0" "") (princ) ) Quote
CAB Posted January 20, 2009 Posted January 20, 2009 Are you trying to run the DIMCONTINUE command with user selections? Or are you trying to select dimensions to update with layer & scale factor? Quote
ebrito Posted January 20, 2009 Author Posted January 20, 2009 I am trying to run dimcontinue with user selections. In other words to have continued dimensions with the "dimscale" of the selected dimension placed in the layer of such selected dimension. Quote
CAB Posted January 20, 2009 Posted January 20, 2009 See how this works for you. (Not perfect.) (defun c:dlcon (/ ent obj) (vl-load-com) (if (and (or (setq ent (entsel "\nSelect Base Dimension")) (prompt "\nNothing Selected") ) (setq obj (vlax-ename->vla-object (car ent))) (or (vlax-property-available-p obj 'ScaleFactor) (prompt "\nNo scale factor.") ) ) (progn (setq cds (getvar "dimstyle")) (setq clay (getvar "clayer")) (command ".-dimstyle" "restore" (vla-get-StyleName obj)) ;;(setvar "dimscale" (vla-get-ScaleFactor obj)) (setvar "clayer" (vla-get-Layer obj)) (vl-catch-all-apply 'vl-cmdf (list "._dimcontinue" "_S")) (while (> (getvar "CMDACTIVE") 0) (command pause) ) (command ".-dimstyle" "restore" cds) (setvar "clayer" clay) ) ) (princ) ) Quote
ebrito Posted January 20, 2009 Author Posted January 20, 2009 Yes it works, but the semicolons in : ;;(setvar "dimscale" (vla-get-ScaleFactor obj)) have to be erased in order to get de dimscale of the picked dimension. The only issue that is not "perfect" is that the dimension has to be picked twice to start. A very good feature is that, the dimensions can be continued to the side of the pick, regardless of the direction in which the original was drafted. Thanks a lot I wish some day I´ll be able to write as "imperfect" as you. Quote
CAB Posted January 20, 2009 Posted January 20, 2009 What are to prompts at the command line when you enter dimcontinue as a command? And after you add one dimension with the command? Quote
Lee Mac Posted January 20, 2009 Posted January 20, 2009 The only issue that is not "perfect" is that the dimension has to be picked twice to start. I suppose you could do it like this: (defun c:dlcon (/ ent obj) (vl-load-com) (if (and (or (setq ent (entsel "\nSelect Base Dimension")) (prompt "\nNothing Selected") ) (setq obj (vlax-ename->vla-object (car ent))) (or (vlax-property-available-p obj 'ScaleFactor) (prompt "\nNo scale factor.") ) ) (progn (setq cds (getvar "dimstyle")) (setq clay (getvar "clayer")) (command ".-dimstyle" "restore" (vla-get-StyleName obj)) (setvar "dimscale" (vla-get-ScaleFactor obj)) (setvar "clayer" (vla-get-Layer obj)) (vl-catch-all-apply 'vl-cmdf (list "._dimcontinue" "_S" ent)) (while (> (getvar "CMDACTIVE") 0) (command pause) ) (command ".-dimstyle" "restore" cds) (setvar "clayer" clay) ) ) (princ) ) Quote
Lee Mac Posted January 20, 2009 Posted January 20, 2009 CAB, A quick question - Upon dissecting your LISP - I cannot find any such vla-get-...xxx functions in the AutoLISP Reference Manual, only vlax-get-property How do you use these vla-get-xxx functions? Cheers Lee Quote
ebrito Posted January 20, 2009 Author Posted January 20, 2009 At te command line the prompt are: Command: _dimcontinue Specify a second extension line origin or [undo/Select] : ( autocad displays a dim line attached to the last placed ) Specify a second extension line origin or [undo/Select] : (If select is chosen, any dimension can be picked and it starts again fron that dimension) Specify a second extension line origin or [undo/Select] : Select continued dimension: Quote
ebrito Posted January 20, 2009 Author Posted January 20, 2009 Thanks CAB and Lee Mac It works perfect. Quote
CAB Posted January 20, 2009 Posted January 20, 2009 Use this code to get the properties: (defun c:dump (/ ent obj) (while (setq ent (entsel "\nSelect entity to get object data: ")) (print) (setq obj (vlax-ename->vla-object (car ent))) (vlax-dump-object obj t) (vlax-release-object obj) (princ "\n") ) (princ) ) Here I selected a line: Select entity to get object data: ; IAcadLine: AutoCAD Line Interface ; Property values: ; Angle (RO) = 6.25243 ; Application (RO) = #<VLA-OBJECT IAcadApplication 00ac8928> ; Color = 256 ; Delta (RO) = (73.8932 -2.2736 0.0) ; Document (RO) = #<VLA-OBJECT IAcadDocument 061ffce4> ; EndPoint = (-21.5502 -543.097 0.0) ; Handle (RO) = "B187" ; HasExtensionDictionary (RO) = 0 ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 068c7ea4> ; Layer = "LayerName" ; Length (RO) = 73.9281 ; Linetype = "ByLayer" ; LinetypeScale = 1.0 ; Lineweight = -1 ; Normal = (0.0 0.0 1.0) ; ObjectID (RO) = 106617208 ; ObjectName (RO) = "AcDbLine" ; OwnerID (RO) = 105390096 ; PlotStyleName = "ByLayer" ; StartPoint = (-95.4433 -540.823 0.0) ; Thickness = 0.0 ; Visible = -1 ; Methods supported: ; ArrayPolar (3) ; ArrayRectangular (6) ; Copy () ; Delete () ; GetBoundingBox (2) ; GetExtensionDictionary () ; GetXData (3) ; Highlight (1) ; IntersectWith (2) ; Mirror (2) ; Mirror3D (3) ; Move (2) ; Offset (1) ; Rotate (2) ; Rotate3D (3) ; ScaleEntity (2) ; SetXData (2) ; TransformBy (1) ; Update () Note that you can modify any Property that is not (RO) Read Only by using (vla-put- obj). You can get any of the properties. Quote
CAB Posted January 20, 2009 Posted January 20, 2009 Also read this thread: http://discussion.autodesk.com/forums/thread.jspa?threadID=366734 Quote
Lee Mac Posted January 21, 2009 Posted January 21, 2009 Ahhh, That is fantastic CAB - I can see now the allure of VL over Common LISP - I suppose getting a property using VL is so much easier than going through the palava of DXF Group Tables... And thanks for the Link - very interesting reading on the two methods. I'm sorry to bother you further, but, why do you have to use: vlax-release-object I have read the ACAD help file and understand that the object cannot be accessed through the variable assigned to it (hope thats correct), but surely the value of this variable is erased by localising it in the main function: (defun c:dump (/ ent obj) Just curious.. 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.