Lisp from autocad that does'nt work

#1
Hi

I'm a beginer using intellicad 13 premium, I was with autocad before !

All my .lisp and acaddoc works but one !

Here is the one that does'nt work ! The goal is to click on 2 mesures, than click on a empty space, and it should give me the result of how much sqare feet it is !

Is there anyone who knows whats wrong with that routine:


---------------------------------------------------------------------------------------------------------------------------------


;;;; calcul des pieds carr ;;;;;
(defun c:aaa ( / dm1 dm2 en1 en2 obj get hgt ins )
(and
(setq dm1 (car (entsel "\nSelect 1st dimlineaer :")))
(or (member '(100 . "AcDbAlignedDimension") (setq en1 (entget dm1)))
(alert "Invalid object.<!>")
)
(setq dm2 (car (entsel "\nSelect 2nd dimlineaer :")))
(or (member '(100 . "AcDbAlignedDimension") (setq en2 (entget dm2)))
(alert "Invalid object.<!>")
)
(setq obj (tblobjname "BLOCK" (cdr (assoc 2 en1))))
(while (and (not hgt) (setq obj (entnext obj)))
(and (= (cdr (assoc 0 (setq get (entget obj)))) "MTEXT")
(setq hgt (assoc 40 get))
)
)
(setq ins (getpoint "\nSpecify location of text area :"))
(entmake (list '(0 . "TEXT") (cons 10 (trans ins 0 1)) (cons 11 (trans ins 0 1)) hgt
(cons 1 (strcat (rtos (LM:roundup (/ (* (cdr (assoc 42 en1)) (cdr (assoc 42 en2))) 144) 0.1) 2) " SQF"))
)
)
)
(princ)
)


---------------------------------------------------------------------------------------------------------------------------


For know, I do aaa, space, than intellicad ask me to click on the firt mesure, than the second one, than I should just click on an empty space and see how much square feet... but it stop working after the second mesure ??


--------------------------------------------------------------------------------------------------------------------------------


The roundup routine in case that it is important would be :

;; Round Up - Lee Mac
;; Rounds 'n' up to the nearest 'm'

(defun LM:roundup ( n m )
((lambda ( r ) (cond ((equal 0.0 r 1e-8) n) ((< n 0) (- n r)) ((+ n (- m r))))) (rem n m))
)


--------------------------------------------------------------------------------------------------------------------------------

It would change my life to have that fonction back in intellicad

Because I tried another routine that I was using in autocad , it was a routine that allowed me to click on many result from the routine that I showed you up here, and click on an empty space again and it was giving me the total sqare feets from all the previous results

This other fonction still works in intellicad , but I can't use it since the first routine does'nt works

Re: Lisp from autocad that does'nt work

#2
Hi Martin,

There is a bit of difference in some Lisp functions between AutoCAD and IntelliCAD.
Please use this attach, it works on CMS ver 13.0

Code: Select all

;;;; calcul des pieds carr ;;;;;
(defun c:aaa (/ dm1 dm2 en1 en2 obj get hgt ins)
  (and
    (setq dm1 (car (entsel "\nSelect 1st dimlineaer :")))
    (or	(member	'(100 . "AcDbAlignedDimension")
		(setq en1 (entget dm1))	)
	(alert "Invalid object.<!>")    )
    (setq dm2 (car (entsel "\nSelect 2nd dimlineaer :")))
    (or	(member	'(100 . "AcDbAlignedDimension")
		(setq en2 (entget dm2))	)
	(alert "Invalid object.<!>")    )
    ;(setq obj (tblobjname "BLOCK" (cdr (assoc 2 en1))))
    ;(while (and (not hgt) (setq obj (entnext obj)))
    ;  (and (= (cdr (assoc 0 (setq get (entget obj)))) "MTEXT")
    ;   (setq hgt (assoc 40 get)) ) )
    (setq hgt (vla-get-textheight (vlax-ename->vla-Object dm1)))
    (setq ins (getpoint "\nSpecify location of text area :"))
    (entmake
      (list
	'(0 . "TEXT")
	(cons 10 (trans ins 0 1))
	(cons 11 (trans ins 0 1))
	(cons 40 hgt)
	(cons 1
	      (strcat
		(rtos (LM:roundup (/ (* (cdr (assoc 42 en1)) (cdr (assoc 42 en2))) 144) 0.1 ) 2 )
		" SQF" )) ) )
    )
  (princ))

;; Round Up - Lee Mac
;; Rounds 'n' up to the nearest 'm'
(defun LM:roundup (n m)
  ((lambda (r)
     (cond ((equal 0.0 r 1e-8) n)
	   ((< n 0) (- n r))
	   ((+ n (- m r))) ) )
    (rem n m)  ))
cron