Jump to content

Manipulating dimension values


silverfish

Recommended Posts

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    9

  • silverfish

    8

  • Ryder

    4

  • irneb

    3

Top Posters In This Topic

Posted Images

Assuming you used Lee's code, then once it's loaded you should have a new command called MacDim. Just type it into the command-line. It'll ask you to select the dimension(s) and specify the alteration value.

 

Edit: As a future tip: If there's a piece of code in the LSP file which starts with

(defun C:

Then the word following it will be the command. Note it's possible that the word could have other characters in it (like - ), but no spaces. Basically acad looks at the name of the function when it's defined (defun = define function), if the name starts with C: then acad adds it as a custom lisp command, otherwise it's just a normal lisp function which you can also call but need to use lisp-like syntax.

 

Also a LSP file may have many of these custom commands, not just one, so look through the whole code for new commands.

Link to comment
Share on other sites

than x irneb, much appreciated everything works well. Only problem i sthat after i use the macdim command my dimensions are no longer rounded off to 5 as they were before applying the command? Any thoughts on this?

Link to comment
Share on other sites

That's because Lee's code overwrites the dim with a new computed string. His code would need some alteration to test these rounding of the dimension so it matches the original dim.

 

Perhaps this:

(defun c:MacDim (/ ss num)
 (vl-load-com)
 (if (and (setq ss (ssget '((0 . "DIMENSION"))))
          (setq num (getreal "\nSpecify Alteration: ")))
   (mapcar
     (function
       (lambda (x)
         (vla-put-TextColor x 1) ; <<-- 1 = Red
           (vla-put-TextOverride x
             (strcat
               (vla-get-TextPrefix x)
                 (rtos [color=red](round [/color](+ (vla-get-Measurement x) num)
                              [color=red](vla-get-RoundDistance x)[/color])
                   (vla-get-UnitsFormat x)
                     (vla-get-PrimaryUnitsPrecision x))
                   (vla-get-TextSuffix x)))))
     (mapcar 'vlax-ename->vla-object
       (vl-remove-if 'listp
         (mapcar 'cadr (ssnamex ss))))))
 (princ))

[color=red](defun round (num fact / mod)
 (if (< (setq mod (rem num fact)) (/ fact 2))
   (- num mod)
   (+ num [u](- fact mod)[/u])))[/color]

Edit: Sorry, stupid mistake on my part ... in a rush!

Edited by irneb
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...