Lisp to select dimension , divide its value by a space , round the number up, and copy it to the clipboard

Lisp to select dimension , divide its value by a space , round the number up, and copy it to the clipboard

the2nd_ofme
Explorer Explorer
570 Views
4 Replies
Message 1 of 5

Lisp to select dimension , divide its value by a space , round the number up, and copy it to the clipboard

the2nd_ofme
Explorer
Explorer

Lisp to select dimension , divide its value by a user manually space ( Distance ) , round the number up, and copy it to the clipboard 

plz 

 

0 Likes
Accepted solutions (1)
571 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

Is "it" that is to be copied to the clipboard the rounded-up number, as text?

Kent Cooper, AIA
0 Likes
Message 3 of 5

the2nd_ofme
Explorer
Explorer
thx for replying
yes it is
0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

In simplest terms, try this:

(defun C:DDC (/ dim div mea num)
  (setq
    dim (car (entsel "\nSelect Dimension object to report on: "))
    div (getdist "\nDivisor distance: ")
    mea (cdr (assoc 42 (entget dim)))
    num
      (+
        (fix (/ mea div))
        (if (= (rem mea div) 0) 0 1)
      )
  )
  (vlax-invoke
    (vlax-get
      (vlax-get (setq htmlfile (vlax-create-object "htmlfile")) 'ParentWindow)
      'ClipBoardData
    )
    'SetData
    "Text"
    (itoa num)
  )
)

That assumes rounding up to mean to the next integer value, and if it divides exactly, it doesn't jump it up by one.

 

It could use enhancements such as a check on the type of object selected [not just that it's a Dimension, but one of a linear nature, not angular and maybe not ordinate], and could report to the command line what it put into the clipboard, and probably some other things.

Kent Cooper, AIA
0 Likes
Message 5 of 5

the2nd_ofme
Explorer
Explorer
u made my day
It took too much of my time searching about it , even I tried to learn the AutoLISP
thx a lot
0 Likes