Jump to content

LISP for Dimensions <> Not Equal to 0


ola.etc

Recommended Posts

Hello, 

 

I was wondering if anyone has/ can whip up a LISP routine that selects any dimension (rotated, aligned, diametric, radial, ect) from the entire drawing (not just a selection) that has a "dim scale linear" value that is <> Not Equal to 1

 

I have been doing it in "qselect" then choosing the options but this is very time consuming. 

 

image.png.dcc0bf8b8554442719aae09570784f6c.png

 

(Where it says "Rotated Dimension" I would like the command to check all dimension types at once, not just rotated) 

 

Thank-you kindly,

Ola 

Edited by ola.etc
Link to comment
Share on other sites

Selects all dimensions in the drawing and then removes them if they have a linear scale factor = 1 or doesn't have a property of linear scale factor. like angular dimensions.

 

this will either say

Drawing Doesn't Have Any Dimension

All Dimension in Drawing Have Linear Scale Factor = 1

or have the dimension's with a scale factor other then 1 selected when lisp is over

 

 

(defun C:foo (/ SS e obj)
  (vl-load-com)
  (if (setq SS (ssget "_X" '((100 . "AcDbDimension"))))
    (foreach e (mapcar 'cadr (ssnamex SS))
      (setq obj (vlax-ename->vla-object e))
      (if (vlax-property-available-p obj 'LinearScaleFactor)
        (if (= 1 (vla-get-LinearScaleFactor obj))
          (ssdel e SS)
        )
        (ssdel e SS)
      )
    )
    (prompt "\nDrawing Doesn't Have Any Dimension")
  )
  (if (and (/= ss nil) (> (sslength SS) 0))
    (sssetfirst nil SS)
    (prompt "\nAll Dimension in Drawing \"Linear Scale Factor = 1\"")
  )
  (princ)
)

 

Edited by mhupp
updated code.
  • Thanks 1
Link to comment
Share on other sites

  • 2 months later...
On 11/29/2021 at 2:14 AM, mhupp said:

Selects all dimensions in the drawing and then removes them if they have a linear scale factor = 1 or doesn't have a property of linear scale factor. like angular dimensions.

 

this will either say

Drawing Doesn't Have Any Dimension

All Dimension in Drawing Have Linear Scale Factor = 1

or have the dimension's with a scale factor other then 1 selected when lisp is over

 

 

(defun C:foo (/ SS e obj)
  (vl-load-com)
  (if (setq SS (ssget "_X" '((0 . "DIMENSION"))))
    (foreach e (mapcar 'cadr (ssnamex SS))
      (setq obj (vlax-ename->vla-object e))
      (if (vlax-property-available-p obj 'LinearScaleFactor)
        (if (= 1 (vla-get-LinearScaleFactor obj))
          (ssdel e SS)
        )
        (ssdel e SS)
      )
    )
    (prompt "\nDrawing Doesn't Have Any Dimension")
  )
  (if (and (/= ss nil) (> (sslength SS) 0))
    (sssetfirst nil SS)
    (prompt "\nAll Dimension in Drawing \"Linear Scale Factor = 1\"")
  )
  (princ)
)

 

This is exactly what I am looking for , thank you so much!   I gave it a test run and it selected the ones I needed but it also selected some dimetric and radial dimensions that did have a dim scale linear of 1, any chance you could take another peak? 

 

Thanks in advanced, I really appreciate it. This helps so much,

Edited by ola.etc
Link to comment
Share on other sites

That drawing had 5 dimensions that are not = to 1 linear scale. the two that I'm guessing you changed to 1.5 for testing.

But the other three dimensions are not 1 either.

 

scale.png.2b39d1d134172fdb40ae6bbdae04827b.png

 

These deviations wouldn't affect any real dimensions and could be ignored by adding a fuzz distance to the if statement.

(if (= 1 (vla-get-LinearScaleFactor obj))
 change to 
(if (equal 1 (vla-get-LinearScaleFactor obj) 0.001)

or change them to linear scale factor of 1

  • Like 1
Link to comment
Share on other sites

Thank you! I didn't realize that these were not at a dim scale linear = 1 because my precision wasn't set as high. Thank you so very much. 

 

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

If you load the lisp at startup (via the start-up suit) then I think the simplest way is to put the line

 

(c:foo)

 

after the lisp routine - once it is loaded it runs, but if you later delete the lisp or whatever you don't need to worry about much more

 

You can also search for acad.lsp file and put the same line in there (search online how to do that if you need to).

 

(I am always a little paranoid about order things load at start up, whether acad.lsp loads before or after a LISP routine - if it is before it tries to run something that isn't loaded and will just move on without it - what you think it has done hasn't and that's another reason I prefer the first option)

  • Agree 1
Link to comment
Share on other sites

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