Jump to content

Recommended Posts

Posted (edited)

Thank you to read my thread

I have this code to plus dim and export to excel ...

 

(defun c:ccd(/ gtt dt sdt ent id str)
(setq dt (ssget '((0 . "DIMENSION")))
sdt (sslength dt)
id 0
gtt 0
str "="
)
(repeat sdt
(setq
 ent (ssname dt id)
    id (1+ id)
 gtt (+ gtt (gt1 ent) )
str (strcat str  (Rtos (gt1 ent) 2 0 ) "+")
 )
)
(Lisped (substr str 1 (1- (strlen str))))
(princ (rtos gtt 2 0 ))
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun gt1(ent / so)
(if (wcmatch(cdr(assoc 1 (entget ent)))"")
 (setq so (cdr(assoc 42 (entget ent))))
 (setq so (atof(cdr(assoc 1 (entget ent)))))
 )
)

this code work great but can someone fix

to round up around 10

example : 3316--->3320 .... ; 3321--->3320 .

Thank you for your help :)

Edited by SLW210
Code Tags
Posted

If I look at the code I see that rtos is used. This should correctly round the gtt value. Maybe the OP is confused by the dimensions in the dwg?

For example:

distance 1 = 4.6; dimension value = 5

distance 2 = 3.5; dimension value = 4

 

4.6 + 3.5 = 8.1; rounded value = 8

Posted

Disregard my previous post. I have misread the OP.

Posted
see : http://www.lee-mac.com/round.html

 

 

 (defun LM:roundm ( n m ) (* m (atoi (rtos (/ n (float m)) 2 0))))

 

 

 (LM:roundm 135.13 10)

-> 140

 (LM:roundm 134.13 10)

-> 130

 

Thank you for reply my post .

But im a newbie .

Would u do me favor , add ur code to my code .

Thank you very much

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