prakashreddy Posted December 14, 2011 Posted December 14, 2011 (edited) Dear ALL, I have small problem reading Dim ordinate Dimensions. I have one function to read all dimensions to convert to editable dimension text in entire drawing. But It is not reading and not changing the some off Ordinate dimensions. Please help me regarding this issue. Find the attached drawing file. With my code it is giving error as “AutoCAD.Application: Object is not open for write” because it is not finding the text at Measurement (RO) My code as follows….. [color=#1f497d][font=Calibri][size=3][font=Calibri](defun edited_dimension (/ aa )[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri](setq ss (ssget "x" (list (cons 0 "DIMENSION"))))[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri](Setq #i 0)[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri](if ss[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (repeat (sslength ss)[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (setq aa (vlax-ename->vla-object (ssname ss #i)))[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (setq bb (vla-get-textoverride aa))[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (cond ((wcmatch bb "*<>*")[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (vla-put-TextOverride[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] aa[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (vl-string-subst (rtos (vla-get-Measurement aa) 2 0) "<>" bb)[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] )[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] )[/font][/size][/font][/color] [size=3][font=Calibri][color=#1f497d][font=Calibri] ((= bb "")[/font][/color][/font][/size] [color=#1f497d][font=Calibri][size=3][font=Calibri] (vla-put-TextOverride[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] aa[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (vl-string-subst (rtos (vla-get-Measurement aa) 2 0) "" bb)[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] )[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] )[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] )[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] (Setq #i (1+ #i))[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri] )[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri])[/font][/size][/font][/color] [color=#1f497d][font=Calibri][size=3][font=Calibri])[/font][/size][/font][/color] RF1-2B.dwg Edited December 14, 2011 by prakashreddy Didnt attach drawing file Quote
Tharwat Posted December 14, 2011 Posted December 14, 2011 What are trying to accomplish , are you willing to add to all dimensions or to remove the from the selected dimensions ? Quote
pBe Posted December 15, 2011 Posted December 15, 2011 With my code it is giving error as [/font][/color]“AutoCAD.Application: Object is not open for write” because it is not finding the text at Measurement (RO)[/font][/size] I dont see anythng wrong with code above (maybe a couple though) Not sure if you use this as a sub, you may want to look at your main code, use VLIDE break on error debug tool to see where the error occur Quote
prakashreddy Posted December 17, 2011 Author Posted December 17, 2011 Mr Thrawat Yes I want to read the all dimensions. But i cant able to read the some Ordinate dimensions specified in the drawing. Quote
prakashreddy Posted December 17, 2011 Author Posted December 17, 2011 Dear PBE The program will break at vl-get-measurement. The error is Automation error. Quote
Tharwat Posted December 17, 2011 Posted December 17, 2011 What are trying to do after reading the ordinate dimensions ? Quote
Tharwat Posted December 17, 2011 Posted December 17, 2011 Consider this as an example to read the measurement of ordinate dimensions to the command line ... (defun c:TesT (/ selectionset) ;;; Tharwat 17. Dec. 2011 ;;; (if (setq selectionset (ssget '((0 . "DIMENSION")))) ((lambda (integer / selectionsetname) (while (setq selectionsetname (ssname selectionset (setq integer (1+ integer)) ) ) (if (eq (cdr (assoc 100 (reverse (entget selectionsetname)))) "AcDbOrdinateDimension" ) (print (if (eq (setq v (cdr (assoc 1 (entget selectionsetname)))) "" ) (cdr (assoc 42 (entget selectionsetname))) (atof v) ) ) ) ) ) -1 ) (princ) ) (princ) ) Quote
Lee Mac Posted December 17, 2011 Posted December 17, 2011 “AutoCAD.Application: Object is not open for write” After a quick glance, the function code itself looks fine to me. Are you evaluating this function from an object reactor callback function? 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.