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

Add calculated text to ordinate dimension

6 REPLIES 6
Reply
Message 1 of 7
plohret
636 Views, 6 Replies

Add calculated text to ordinate dimension

Hello!  I'm hoping someone can help me.  Currently, when I do drawings, I give my machinists drawings with each point, and they program their machines.  To do that, they calculate the round part diameters, which is basically 5" - 2x<Dim>.   

 

I'd like it if I could give them drawings with the real number, and in parenthesis next to it, 5-2x<Dim>.  

 

 I've attached a jpg of what I normally give them and how I'd like it to look. Is this something do-able via a macro or something?  Thanks in advance

6 REPLIES 6
Message 2 of 7
Kent1Cooper
in reply to: plohret


@plohret wrote:

.... 

I'd like it if I could give them drawings with the real number, and in parenthesis next to it, 5-2x<Dim>.  

.... Is this something do-able via a macro or something?  ....


Yes, I'm sure it is.  Would you want to do it in the process of drawing Ordinate Dimensions, or would want to select existing Dimensions and have their text content altered?  [I ask because I see one in your edited image that doesn't have that parenthetical value.]

Kent Cooper, AIA
Message 3 of 7
plohret
in reply to: plohret

I'd much prefer to do it at the time I create the dimension, but selecting the dimension and running a macro works too.

 

 I'd like to have one command for normal ordinate (which is obviously the regular dimordinate command) and another one (dimord2 or something) that would create the modified text.

 

 Thanks!

Message 4 of 7
Kent1Cooper
in reply to: plohret


@plohret wrote:

I'd much prefer to do it at the time I create the dimension, but selecting the dimension and running a macro works too.

 

 I'd like to have one command for normal ordinate (which is obviously the regular dimordinate command) and another one (dimord2 or something) that would create the modified text.

 

 Thanks!


The select-existing approach will be a lot simpler, because of the nature of Ordinate Dimensions being ambiguous about whether it's the X or Y ordinate you're after, determined dynamically as you move the cursor.  [You can't dig the measured value out of the entity data until after the Dimension is drawn.]  If you're willing to have the parenthetical value not appear until after you designate the X-or-Y choice, and not as you're moving the cursor, or to specify X or Y in advance [that is, have separate commands, or select an option within a command], it would be comparatively easy to do it as the Dimensions are created rather than afterwards.  But it may be possible even to drag it with the parenthetical value already included.  Altering them afterwards would be pretty straightforward.

 

I'll probably play with that later, but I'm on the way out the door....

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

I don't need to see it in-process, only after creation.

Message 6 of 7
3wood
in reply to: plohret

Please try the following code.

;;; DIMSUFFIX.lsp by 3wood
;;; https://sites.google.com/site/cadkits/home
(defun C:DIMSUFFIX (/ ss n vl-obj) 
  (setq ss (ssget '((0 . "DIMENSION"))))
  (if ss
    (progn
      (setq n 0)
      (repeat (sslength ss)
	(setq vl-obj (vlax-ename->vla-object (ssname ss n)))
	(vla-put-TextSuffix vl-obj
	  (strcat
	    " ("
	  (rtos (- 5.0 (* 2.0 (vla-get-Measurement vl-obj)))
		(vla-get-Unitsformat vl-obj)
		(vla-get-PrimaryUnitsPrecision vl-obj)
		)
	    ")"
	    )
	  )
	(setq n (1+ n))
	)
      )
    )
  )

 

 

Message 7 of 7
plohret
in reply to: 3wood

I had to add (vl-load-com) in there but it worked.  

 

After playing with this some, I'm probably better off putting all my dimensions in with dimordinate then running this on the ones I want the extra text on, so it's perfect.  Thanks!

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

Post to forums  

Autodesk Design & Make Report

”Boost