Identify dimensions with a style override

Identify dimensions with a style override

wai1954
Advocate Advocate
1,050 Views
9 Replies
Message 1 of 10

Identify dimensions with a style override

wai1954
Advocate
Advocate

G'day,

 

I am trying to get some pointers on how to find if a dimension has had a style override applied.

 

I am doing some work for a company making panel form buildings and sheds and it is standard practice to show some dimensions 1 mm less than actual as timber can shrink and swell causing assemblies to get stuck in jigs.

 

Unfortunately does not have the ability to do this and so you have to resort to style overrides, in particular DIMRND and DIMLFAC. Depending on the value of DIMRND, you can still end up with a dimension not changing even though there has been a substantial change when the assembly is altered.

 

I am trying to find out how dimensions with these overrides can be flagged so that when the drawing is altered, these dimensions can use a different colour to indicate the dimension may not reflect the true size.

 

Thanks.

wai1954 (Ian A. White)
0 Likes
Accepted solutions (1)
1,051 Views
9 Replies
Replies (9)
Message 2 of 10

ВeekeeCZ
Consultant
Consultant

This will color dims in yellow if one of those property overrides is applied.

 

(defun c:DimOverrideColoring ( / LM:getdimxdata ss i ent )

  ;; Lee Mac: http://www.lee-mac.com/mask.html
  (defun LM:getdimxdata ( dim / lst ovr )
    (setq lst (cddr (member '(1000 . "DSTYLE") (cdadr (assoc -3 (entget dim '("acad")))))))
    (while (and lst (not (equal '(1002 . "}") (car lst))))
        (setq ovr (cons (list (car lst) (cadr lst)) ovr)
              lst (cddr lst)))
    (reverse ovr)
)

  ; --------------------------------------------------------------------------------------------------
  
  (if (setq ss (ssget ":L" '((0 . "DIMENSION"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (if (and (setq ovr (LM:getdimxdata ent))
	       (or (member 45 (mapcar 'cdar ovr))    	;DIMRND
		   (member 144 (mapcar 'cdar ovr))))	;DIMLFAC
	(setpropertyvalue ent "Color" 2))))
  (princ)
  )
0 Likes
Message 3 of 10

dlanorh
Advisor
Advisor
0 Likes
Message 4 of 10

doaiena
Collaborator
Collaborator
Accepted solution

I seem to be a bit late to the party. I wrote some code, so might as well post it.

(defun c:test ( / ss ctr obj dType dVal dTypes dVals data col0 col1 col2)

(if (setq ss (ssget "X" '((0 . "DIMENSION") (-3 ("ACAD")))))
(progn

(setq ctr 0)
(repeat (sslength ss)
(setq obj (vlax-ename->vla-object (ssname ss ctr)))

(vla-GetXData obj "ACAD" 'dType 'dVal)
(if (and dType dVal (= (variant-value (vlax-safearray-get-element dVal 1)) "DSTYLE"))
(progn

(setq dTypes (vlax-safearray->list dType))
(setq dVals (mapcar 'variant-value (vlax-safearray->list dVal)))
(setq data (mapcar '(lambda (typ val) (if (= typ 1070) val)) dTypes dVals))

(setq col0 1);DIMRND + DIMLFAC color
(setq col1 2);DIMRND color
(setq col2 3);DIMLFAC color

(cond
((and (vl-position 45 data) (vl-position 144 data)) (vla-put-color obj col0))
((vl-position 45 data) (vla-put-color obj col1))
((vl-position 144 data) (vla-put-color obj col2))
)
))

(setq ctr (1+ ctr))
);repeat

)
(princ "\nNo Dimensions with overrides found.")
);if ss

(princ)
);defun
0 Likes
Message 5 of 10

wai1954
Advocate
Advocate

Thanks everyone for your help. Very much appreciated.

wai1954 (Ian A. White)
0 Likes
Message 6 of 10

wai1954
Advocate
Advocate

Unfortunately, one little quirk.

 

I use transspatial  dimensioning (dimensions in Layout space through a viewport) and for them, AutoCAD uses a negative value of DIMLFAC and so all dimensions get flagged as an override.

 

I will have to look at the code in more detail to see how to check for a negative value of DIMLFAC and then ignore that one.

wai1954 (Ian A. White)
0 Likes
Message 7 of 10

ВeekeeCZ
Consultant
Consultant

Once you decide you need some help we might need to better understand the issue - post some dwg with such texts, maybe use the SCREENCAST  are record your doing.

0 Likes
Message 8 of 10

wai1954
Advocate
Advocate

Sorry guys, not trying to be vague, just a little busy.

 

I have attached a small drawing that is typical of the issue.

 

Hope this helps.

wai1954 (Ian A. White)
0 Likes
Message 9 of 10

ВeekeeCZ
Consultant
Consultant

Here is how your suggested approach could look like in code.

 

(defun c:DimOverrideColoring ( / LM:getdimxdata ss i ent )

  ;; Lee Mac: http://www.lee-mac.com/mask.html
  (defun LM:getdimxdata ( dim / lst ovr )
    (setq lst (cddr (member '(1000 . "DSTYLE") (cdadr (assoc -3 (entget dim '("acad")))))))
    (while (and lst (not (equal '(1002 . "}") (car lst))))
        (setq ovr (cons (list (car lst) (cadr lst)) ovr)
              lst (cddr lst)))
    (reverse ovr)
)

  ; --------------------------------------------------------------------------------------------------
  
  (if (setq ss (ssget ":L" '((0 . "DIMENSION"))))
    (repeat (setq i (sslength ss))
      (setq ent (ssname ss (setq i (1- i))))
      (if (and (setq ovr (mapcar '(lambda (x) (cons (cdar x) (cdadr x))) (LM:getdimxdata ent)))
	       (or (assoc 45 ovr)    	;DIMRND
		   (and (assoc 144 ovr)	;DIMLFAC
			(not (vl-position (atof (rtos (cdr (assoc 144 ovr)) 2 4)) '(-0.1 -0.2 -0.4 -0.5 -2. -2.5 -5. -10. -20. -25.)))) ; make sure they are all real! -10.
		   ))
	(setpropertyvalue ent "Color" 2))))
  (princ)
  )
0 Likes
Message 10 of 10

wai1954
Advocate
Advocate

Thanks a lot for that.

 

I will have a look at it tomorrow and report back as it is now a little before 10:30 pm :D.

 

Thanks again. Much appreciated.

wai1954 (Ian A. White)
0 Likes