Filter object dim?

Filter object dim?

Anonymous
Not applicable
1,716 Views
10 Replies
Message 1 of 11

Filter object dim?

Anonymous
Not applicable

Hello all,

 

I have some dimension in drawing attached.

Now i mean select all and get select lst_dim_row 1, row 2, row 3 (pls see attached file)

 

Can someone tell the way do it ?

 

Thanks.

0 Likes
Accepted solutions (1)
1,717 Views
10 Replies
Replies (10)
Message 2 of 11

Ranjit_Singh
Advisor
Advisor

If you mean selecting all dimensions

(ssget "_x" '((0 . "DIMENSION")))

If you want to select everything else

 

(ssget "_x" '((0 . "~DIMENSION")))
0 Likes
Message 3 of 11

Anonymous
Not applicable

Thanks for repply Ranjit.Singh.

 

 

I mean select all DIM then creat list entity,

(setq ss (ssget '((0 . "DIMENSION"))))

(setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))

 

My question: from lst, how can creat lst_ent_1, lst_ent_2, lst_ent_3 ?

 

 

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... some dimension in drawing attached.

....


What's attached is a .rar file, which my computer doesn't know what to do with.  Can you attach a .dwg file, or an image?

Kent Cooper, AIA
0 Likes
Message 5 of 11

Anonymous
Not applicable

Hi Kent,

 

My pc attach dwg long time, i don't know why.

 

To solve, i attached jpg file following, pls see it.

I can not login my account, this my friend account. Maybe pc error. 


Thanks.

0 Likes
Message 6 of 11

ВeekeeCZ
Consultant
Consultant

@Anonymous' dwg from rar archive.

 

 

0 Likes
Message 7 of 11

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

I mean select all DIM then creat list entity,

(setq ss (ssget '((0 . "DIMENSION"))))

(setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))

 

My question: from lst, how can creat lst_ent_1, lst_ent_2, lst_ent_3 ? 


My question is then:  What do you plan to do with the results?  I'm just wondering whether you might prefer to have them in selection sets rather than lists.  It would be easier to do certain things with them that way, such as put them on different Layers.

 

In either case, I am imagining a way to do it.  It's complicated [but not made impossible] by the fact that in your sample drawing, most of the Dimensions are of the ROTATED variety, but one is ALIGNED.

Kent Cooper, AIA
0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant

@Kent1Cooper wrote:

.... I am imagining a way to do it.  ....


Try this out.  Very lightly tested, but it seems to work in the example drawing.  Note the NOTE in the middle.

 

Spoiler
(defun C:DPL ; = Dimension Position Lists
  (/ ss ddata drot listnum n listAll dim Ystr Ylist)
  (prompt "\nTo separate Dimensions into dimension-line-Position-based lists,")
  (if (setq ss (ssget '((0 . "DIMENSION") (-4 . "<OR") (70 . 32) (70 . 33) (-4 . "OR>"))))
    ;; find only DIMLINEAR/DIMROTATED [32] or DIMALIGNED [33] types
    (progn ; then
      (setq
        ddata (entget (ssname ss 0)); the first one
        drot ; rotation angle
          (if (member '(70 . 32) ddata); Rotated
            (cdr (assoc 50 ddata)); then -- defined angle
            (angle (cdr (assoc 13 ddata)) (cdr (assoc 14 ddata))); else [Aligned] -- between def. points
          ); if
        listnum 0 ; base for suffix number for first list variable names
      ); setq
      (command "_.ucs" "_z" (angtos drot (getvar 'aunits) 8)); to compare alignments in Y direction
      (repeat (setq n (sslength ss))
        (setq listAll
          (cons
            (list
              (setq dim (ssname ss (setq n (1- n)))); entity name
              (cadr (trans (cdr (assoc 10 (entget dim))) 0 1)); Y coordinate in current UCS
            ); list
            listAll
          ); cons
        ); setq
      ); repeat
      (setq listAll (vl-sort listAll '(lambda (a b) (> (cadr a) (cadr b)))))
        ;; in order of Y coordinate in current UCS, highest to lowest
        ;; NOTE:  Sort order suited to list variable names as requested in sample drawing and
        ;;   direction in which rotation of first Dimension in 'ss' was designated; if sorted with
        ;;   < instead, OR if Dimension rotation had been designated in other direction, then
        ;;   variable names on lists would have gone in other direction.  If sequence of list
        ;;   names needs to go in a particular WCS direction, that could be done.
      (command "_.ucs" "_previous"); done with that
      (foreach dimY listAll
        (if (member (setq Ystr (rtos (cadr dimY) 2 1)) Ylist); any at that level already
          (set (read (strcat "lst_ent_" (itoa (1+ (vl-position Ystr Ylist)))))
            (cons (car dimY) (eval (read (strcat "lst_ent_" (itoa (1+ (vl-position Ystr Ylist)))))))
          ); set -- then; add it to appropriate list
          (progn ; else -- start new list and put this one in it
            (set (read (strcat "lst_ent_" (itoa (setq listnum (1+ listnum))))) (list (car dimY)))
            (setq Ylist (append Ylist (list Ystr))); add Y coordinate string to list of values
          ); progn
        ); if
      ); foreach
    ); progn
    (prompt "\nNo Dimension(s) of appropriate type(s) selected.")
  ); if
  (princ)
); defun
Kent Cooper, AIA
0 Likes
Message 9 of 11

Anonymous
Not applicable

Thanks for you solution, Kent ^_^

 

Rotate ucs then sort lst.

 

I wrote my code, but not exacty lst_ent_1, lst_ent_2, lst_ent_3. Pls tell me where is wrong ? 

 

(defun c:test (/ ss lst)
  (setq ss (ssget '((0 . "DIMENSION"))))
  (setq lst (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss))))
  (dim_ lst)
)

(defun dim_ (l / lst lst_min lst_max lst_mid)

   ;;;;changed Y point 13 = Y point 14
  (command "UCS"
	   "3"
	   (cdr (assoc 14 (entget (car l))))
	   (cdr (assoc 13 (entget (car l))))
	   (cdr (assoc 10 (entget (car l))))
  )
 
  (setq
    lst	(vl-sort
	  l
	  '(lambda (e1 e2)
	     (<	(cadr (trans (cdr (assoc 11 (entget e1))) 0 1))
		(cadr (trans (cdr (assoc 11 (entget e2))) 0 1))
	     )
	   )
	)
  )					;setq
  
  ;;sorted true

  (setq	lst_min
	 (vl-remove-if
	   '(lambda (e)
	      (> (cadr (trans (cdr (assoc 10 (entget e))) 0 1))
		 (cadr (trans (cdr (assoc 10 (entget (car lst)))) 0 1))
	      )
	    )
	   l
	 )
  )					;setq
  ;Wrong lst_min

  (setq	lst_max
	 (vl-remove-if
	   '(lambda (e)
	      (<
		(cadr (trans (cdr (assoc 10 (entget e))) 0 1))
		(cadr
		  (trans (cdr (assoc 10 (entget (car (reverse lst))))) 0 1)
		)
	      )
	    )
	   l
	 )
  )
  ;Wrong lst_max

  (setq lst_mid l)
  (foreach o lst_min
    (setq lst_mid (vl-remove o lst_mid))
  )
  (foreach o lst_max
    (setq lst_mid (vl-remove o lst_mid))
  )
  ;Wrong lst_mid

  
  (foreach dim lst_min
    (redraw dim 3)
  )
;;;  (foreach dim lst_mid
;;;    (redraw dim 3)
;;;  )
;;;  (foreach dim lst_max
;;;    (redraw dim 3)
;;;  )
)

Thank you very much.

0 Likes
Message 10 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

@Anonymous wrote:

.... 

I wrote my code, but not exacty lst_ent_1, lst_ent_2, lst_ent_3. Pls tell me where is wrong ? 

 

....
  (command "UCS"
	   "3"
	   (cdr (assoc 14 (entget (car l))))
	   (cdr (assoc 13 (entget (car l))))
	   (cdr (assoc 10 (entget (car l))))
  )
....
(setq lst_min (vl-remove-if '(lambda (e) (> (cadr (trans (cdr (assoc 10 (entget e))) 0 1)) (cadr (trans (cdr (assoc 10 (entget (car lst)))) 0 1)) ) ....

One problem may be in the red part.  In an Aligned Dimension, the direction between the definition points [13 & 14] will always be the same as the direction of the dimension line [that's what defines that direction].  But it will not always be the same in a Rotated Dimension [which all but one of them in your sample drawing are].  That's why my code makes the distinction between the two types, and if the one it's using to change the UCS is a Rotated Dimension, uses its defined rotation angle [regardless of the definition point relationship], but if it's an Aligned Dimension, uses the 13-to-14 angle.  That's also why it uses the UCS rotate-around-the-Z-axis option rather than the 3-point option.

 

Another possible problem may be in the blue part [and the similar part with the (<) function for lst_max].  The resulting extracted and translated Y coordinate values may vary way down at the 12th decimal place, or something, in which case (<) and (>) may read the relationships [between values you would consider equal] differently than you expect.  That's why I didn't use the Y values directly themselves, but turned them into text strings with a specific number of decimal places, which rounds them off so that a comparison of not-truly-exactly-equal Y coordinates can find them to be equal enough to classify them as being in the same row.  It could also be done with (equal) functions with fuzz factors.

 

Another comment:  I didn't try these kinds of different situations, but mine should work with any number of rows of collinear dimensions, not just the 3 that yours seems designed for.  Of course, your purposes may always be served with 3, so it may not matter.

 

[And a little warning about mine....  It doesn't localize the lst_ent_# variables, so that the resulting lists will be available to you afterwards.  But that means that if you run it more than once in the same editing session of the same drawing, you should set those to nil first, or Dimensions from subsequent runs will be added into lists of those from earlier runs.  That wiping out could be built into the beginning, if it makes sense to do it that way.]

Kent Cooper, AIA
0 Likes
Message 11 of 11

Anonymous
Not applicable

Ahhhhh, i see.

 

not-truly-exactly-equal Y.

 

So i change to:

 (+ (cadr (trans (cdr (assoc 10 (entget (car lst)))) 0 1)) (getvar "DIMGAP")) for lst_min

 (- (cadr (trans (cdr (assoc 10 (entget (car lst)))) 0 1)) (getvar "DIMGAP")) for lst_max

 

It return exactly what i mean.

 

[And a little warning about mine....  It doesn't localize the lst_ent_# variables, so that the resulting lists will be available to you afterwards.  But that means that if you run it more than once in the same editing session of the same drawing, you should set those to nil first, or Dimensions from subsequent runs will be added into lists of those from earlier runs.  That wiping out could be built into the beginning, if it makes sense to do it that way.]

 

Yes, i have 

(setq lst nil lst_min nil lst_max nil lst_mid nil)

And 

acet-error-init

acet-error-restore

 

Kent, thank you so much for your solution. ^_^

Man Happy

0 Likes