Jump to content

Recommended Posts

Posted

Hi everyone,

 

I'm experiencing a Problem using the GetExcel.lsp by Terry Miller (URL: http://web2.airmail.net/terrycad).

My Lisp-Routine adds up line lenghts of up to several Kilometers. At 1,000,000.00 mm, autolisp stores this Number in scientific notation (1.0e006 ). As it gets passed into the PutCell function of GetExcel, it's value is still in the order of Magnitude of e006. But when I open the Excel file, this increased by 5 oom to e011. 

Is there a smart way to fix this?

 

I don't think I made an error in the function counting the line lengths, but have it anyways 😅

(defun linlen (_sslin / _linLenTot count _linLen _ssline)
	(if _sslin 
		(progn 
			(setq _linLenTot 0 count 0)
			(repeat (sslength _sslin) ;; add up all the lentghs
				(setq _ssline (entget (ssname _sslin count))
					P1 (cdr (assoc 10 _ssline))
					P2 (cdr (assoc 11 _ssline))
					_linLen (distance P1 P2)
				) ;; end setq
				(setq _linLenTot (+ _linLenTot _linLen)
					count (+  1 count)
				) ;; end setq
			) ;; end repeat
		) ;; end progn
		(setq _linLenTot "No line found.") ;; if there's no line detected, print this instead
	) ;; end if
	(eval _linLenTot)
)

 

Cheers Seb

Posted

The link is not working, and your code looks OK, so the problem must be in the getExcel lisp.

Posted (edited)

If you want to force the result to display in a particular format without modifying the GetExcel function to apply formatting to the target Excel cell directly, use the rtos function to supply a string to GetExcel instead of a double.

 

For example, change:

(eval _linLenTot)

To:

(rtos _linLenTot)

The above will format the result using your settings for LUNITS & LUPREC; if instead you want to apply a specific format, supply the units & precision arguments to the rtos function, e.g.:

(rtos _linLenTot 2 2)

The use of eval is not required.

Edited by Lee Mac

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