Select all horizontal dimensions in LISP

 Hi all,

I'm looking for a way to select either all of the horizontal or vertical dimensions in a drawing through a lisp program. Ideally I want to select all the vertical dimensions then change the properties of certain ones if they meet a condition to force the text inside of the arrows. If anyone can think of a way to do this it'd be much appreciated.

Comments

  • What's the other condition? That might be easier to filter for than vertical orientation.

    The following selects all horizontal dimensions (except for ones that have been rotated 180 degrees):
    [code](defun c:QDHX ( / ss1 ss2)
    (princ "QDHX selects all Horizontal Dimensions in the file.  ")
    (setq ss1 (ssget "X" '((0 . "DIMENSION"))))
    (if ss1 (progn (sssetfirst nil ss1) (setq ss2 (ssget "P" '((50 . 0.0)))) ) )
    (sssetfirst nil nil)
    (if ss2 (sssetfirst nil ss2)
      (progn (princ "\n ...none found.") (princ) )
      )
    )[/code]

    I would have thought I could change the 0.0 to 1.5708 to make it select vertical dimensions (or 3.14159 to make it select 180-degree-rotated horizontal dimensions), but that didn't work. Perhaps someone else will explain why. And how to filter for two group codes at once instead of using two ssgets.
  • I would have thought I could change the 0.0 to 1.5708 to make it select vertical dimensions (or 3.14159 to make it select 180-degree-rotated horizontal dimensions), but that didn't work. Perhaps someone else will explain why. And how to filter for two group codes at once instead of using two ssgets.


    I would expect that this is due to a rounding error. For example
    [code](= 1.5078 (/ pi 2.0))[/code] will return nil
    but if you use the equal function instead, then you can apply some 'fuzz' to your comparison
    [code](equal 1.5078  (/ pi 2.0) 0.1)[/code] will return T

    Regards,

    Jason Bourhill

    CAD Concepts 


  • [code](defun c:SelHor ( / fuzz)
      (setq fuzz 1e-8)
      (sssetfirst
        nil
        (ssget
          "_X"
          (list
            '(100 . "AcDbRotatedDimension")
            '(-4 . "<OR")
              '(-4 . "<AND")
                '(-4 . "<")
                (cons 50 fuzz)
                '(-4 . ">")
                (cons 50 (- fuzz))
              '(-4 . "AND>")
              '(-4 . "<AND")
                '(-4 . "<")
                (cons 50 (+ pi fuzz))
                '(-4 . ">")
                (cons 50 (- pi fuzz))
              '(-4 . "AND>")
              '(-4 . "<AND")
                '(-4 . "<")
                (cons 50 (+ (- pi) fuzz))
                '(-4 . ">")
                (cons 50 (- (- pi) fuzz))
              '(-4 . "AND>")
            '(-4 . "OR>")
          )
        )
      )
    )[/code]
    [code](defun c:SelVer ( / fuzz)
      (setq fuzz 1e-8)
      (sssetfirst
        nil
        (ssget
          "_X"
          (list
            '(100 . "AcDbRotatedDimension")
            '(-4 . "<OR")
              '(-4 . "<AND")
                '(-4 . "<")
                (cons 50 (+ (* pi 0.5) fuzz))
                '(-4 . ">")
                (cons 50 (- (* pi 0.5) fuzz))
              '(-4 . "AND>")
              '(-4 . "<AND")
                '(-4 . "<")
                (cons 50 (+ (* pi 1.5) fuzz))
                '(-4 . ">")
                (cons 50 (- (* pi 1.5) fuzz))
              '(-4 . "AND>")
              '(-4 . "<AND")
                '(-4 . "<")
                (cons 50 (+ (* pi -0.5) fuzz))
                '(-4 . ">")
                (cons 50 (- (* pi -0.5) fuzz))
              '(-4 . "AND>")
              '(-4 . "<AND")
                '(-4 . "<")
                (cons 50 (+ (* pi -1.5) fuzz))
                '(-4 . ">")
                (cons 50 (- (* pi -1.5) fuzz))
              '(-4 . "AND>")
            '(-4 . "OR>")
          )
        )
      )
    )[/code]
  • Very clever Roy. A very good example of the power of the ssget function through the use of filters


    Regards,

    Jason Bourhill

    CAD Concepts 


This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. Click one of the buttons on the top bar to get involved!