Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select same type of dimensions

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
CADaSchtroumpf
625 Views, 6 Replies

Select same type of dimensions

Hi,

 

I try to filter a type of dimension, but Autodesk have mixed integer value whith bit control (0 1 2 3 4 5 6) & (32 64 128).

I make this, but is works only with linear dimension (other bolean don't work).

Have you an alternate solution ?

 

 

(defun c:sel_same_dim ( / js dxf_ent l_70)
  (princ "\nSelect a dim type model: ")
  (while (null (setq js (ssget "_+.:E:S" '((0 . "DIMENSION")))))
    (princ "\nWait a dim select!")
  )
  (setq
    dxf_ent (entget (ssname js 0))
    l_70 (vl-remove (rem (rem (rem (cdr (assoc 70 dxf_ent)) 32) 64) 128) '(6 5 4 3 2 1 0))
  )
  (sssetfirst nil
    (ssget "_X"
      (append
        '((0 . "DIMENSION"))
        (list (assoc 8 dxf_ent))
        (list (assoc 3 dxf_ent))
        (list (assoc 410 dxf_ent))
        '((-4 . "<AND"))
        (apply
          'append
          (mapcar
            '(lambda (x) (list (cons -4 "<NOT") (cons -4 "&") (cons 70 x) (cons -4 "NOT>")))
            l_70
          )
        )
        '((-4 . "AND>"))
      )
    )
  )
)

 

 

6 REPLIES 6
Message 2 of 7
pbejse
in reply to: CADaSchtroumpf

wont this do what you need?

 

(defun c:test (/ js)
  (while (null (setq js (ssget "_+.:E:S" '((0 . "DIMENSION")))))
    (princ "\nWait a dim select!")
    )

  (sssetfirst
    nil
    (ssget "_X" (list '(0 . "DIMENSION") (assoc 70 (entget (ssname js 0)))))
    )
  (princ)
  )

 

 

or something else you want to filter?

 

EDIT: are you wanting to select dimensions with a particualr condition? like which one have overrides?

or even  something more sinister than that?

 

 

 

 

 

Message 3 of 7
CADaSchtroumpf
in reply to: pbejse

 


pbejse a écrit :

EDIT: are you wanting to select dimensions with a particualr condition? like which one have overrides?

or even  something more sinister than that?

 


Yes,

 

But with your help, i have find easy way for remove bit control 128 and also 64, thank you !

 

 

(defun c:sel_same_dim (/ js dxf_70)
  (princ "\nSelect a dim type model: ")
  (while (null (setq js (ssget "_+.:E:S" '((0 . "DIMENSION")))))
    (princ "\nWait a dim select!")
  )
  (setq dxf_70 (assoc 70 (entget (ssname js 0))))
  (sssetfirst
    nil
    (ssget "_X"
      (list
        '(0 . "DIMENSION")
        '(-4 . "<OR")
          dxf_70
          (cons 70 (+ (cdr dxf_70) 128))
          (cons 70 (+ (cdr dxf_70) 64))
          (cons 70 (- (cdr dxf_70) 128))
          (cons 70 (- (cdr dxf_70) 64))
        '(-4 . "OR>")
      )
    )
  )
  (princ)
)

 

 

Message 4 of 7
Kent1Cooper
in reply to: pbejse


@pbejse wrote:

wont this do what you need?

 

....
  (sssetfirst
    nil
    (ssget "_X" (list '(0 . "DIMENSION") (assoc 70 (entget (ssname js 0)))))
    )
....

....


That should work if they wanted only Dimensions of not only the same type [rotated vs. radial vs. aligned vs. ordinate vs. ...], but [except for Ordinate Dimensions] with the same text position basis [i.e. default vs. dragged elsewhere].  For instance, linear/rotated dimensions have a 70-code value of 32 if the text is at the default location, but 160 if it's been repositioned.  It's similar for other types -- add 128 for non-default text positions.  For ordinate dimensions, it's different -- those that measure in the Y/latitude direction have a 70-code value of 38, but those in the X/longitude direction have 102.  So filtering for just the 70-code value when the selected Dimension is an Ordinate type wouldn't find all Ordinate Dimensions, but would only find the X-ordinate ones if that's the type of the selected one.  Similarly, for a linear/dimension/radius/angular dimension, if the selected one has its text at the default position, such a filter will find only those others with default-position text, rather than all those of the same type.

 

One way around the problem would not be applicable within a filter in (ssget), but could be applied to a selection set of all Dimension entities, with effectively the same result.  Look at the ObjectName VLA property of each entity.  That is "AcDbOrdinateDimension" for both X- and Y-ordinate Dimensions; it's "AcDbRotatedDimension" for all Linear/Rotated Dimensions, whether the text is in the default location or not; and so on for other types.  For any Dimension with a different ObjectName property from the selected reference Dimension, take it out of the selection set.

Kent Cooper, AIA
Message 5 of 7
pbejse
in reply to: Kent1Cooper

hmmmn. i knew theres more to it that just "same type"...

oh well.... gotta run....

 

i'll check this thread tommorrowfor updates

 

 

 

 

 

 

 

Message 6 of 7


@CADaSchtroumpf wrote:

.... 

....
  (setq dxf_70 (assoc 70 (entget (ssname js 0))))
  (sssetfirst
    nil
    (ssget "_X"
      (list
        '(0 . "DIMENSION")
        '(-4 . "<OR")
          dxf_70
          (cons 70 (+ (cdr dxf_70) 128))
          (cons 70 (+ (cdr dxf_70) 64))
          (cons 70 (- (cdr dxf_70) 128))
          (cons 70 (- (cdr dxf_70) 64))
        '(-4 . "OR>")
      )
    )
  )
....

I would think you could shorten that a little, by stripping any 64 or 128 out of the selected object's 70 code to get the "base" dimension type value.  Then you'd only need to check for that and the possible addition of 64 or 128, and not also for the possible subtraction.  You can strip both 64 and 128 out at once with (rem [value] 64).

 

....
  (setq dxf_70base (rem (cdr (assoc 70 (entget (ssname js 0)))) 64))
  (sssetfirst nil
    (ssget "_X"
      (list
        '(0 . "DIMENSION")
        '(-4 . "<OR")
          (cons 70 dxf_70base)
          (cons 70 (+ dxf_70base 128))
          (cons 70 (+ dxf_70base 64))
        '(-4 . "OR>")
      )
    )
  )
....

 

Kent Cooper, AIA
Message 7 of 7

Good remark, it's was effectively shortest and is work well.
Thank Kent

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost