Jump to content

Reading Dimordinate Dimensions


Recommended Posts

Posted (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 by prakashreddy
Didnt attach drawing file
Posted

What are trying to accomplish , are you willing to add to all dimensions or to remove the from the selected dimensions ?

Posted

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

Posted

Mr Thrawat

Yes I want to read the all dimensions. But i cant able to read the some Ordinate dimensions specified in the drawing.

Posted

Dear PBE

The program will break at vl-get-measurement. The error is Automation error.

Posted

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)
)

Posted
“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?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...