Jump to content

Recommended Posts

Posted

Hi everyone,

I'm intersted in runing a lisp on a file that is closed, is this possible . can i also run a lisp on 2 drawings at a time ?

:lol: seems scrpit file is best used in this situation

Posted

my next question is about how i should delete a line of certain lentgth say 1'

Posted
 
(defun dlfoot ()
(setvar "cmdecho" 0)
(setq pt1 (getvar "limmin"))
(setq pt2 (getvar "limmax"))
(setq ss1 (ssget "w" pt1 pt2))
(ssget "X" (list (cons 0 "line")))
???
(comannd "erase" ss1"")
(command redraw")
(setvar "cmdecho" 1)
(princ)
)

Posted

Perhaps:

 

(defun c:dlfoot  (/ Tol ss eLst pt1 pt2)
 (vl-load-com)
 (setq Tol 0.001)
 (if (setq ss (ssget "X" (list (cons 0 "LINE")
                            (if (getvar "CTAB")
                              (cons 410 (getvar "CTAB"))
                              (cons 67 (- 1 (getvar "TILEMODE")))))))
   (progn
     (foreach x  (mapcar 'cadr (ssnamex ss))
       (setq eLst (entget x)
             pt1  (cdr (assoc 10 eLst))
             pt2  (cdr (assoc 11 eLst)))
       (if (not (equal (distance pt1 pt2) 1.0 Tol))
         (ssdel x ss)))
     (if (not (zerop (sslength ss)))
       (command "_erase" ss "")))
   (princ "\n<!> No Lines Found <!>"))
 (princ))

Posted

your coding has gotten so advanced so fast .well mine has fallen behind quite a bit. mostly cause my cad manager doen'st belive in "wasting time" i wish he could meet u :lol:

Posted
your coding has gotten so advanced so fast .well mine has fallen behind quite a bit. mostly cause my cad manager doen'st belive in "wasting time" i wish he could meet u :lol:

 

Haha - my old manager didn't like me writing code during work either - but it does save you time :)

 

Bear in mind with the code above, I have included a Tolerance in the code, at the top (currently set to 0.001), but you may wish to set this is something lower (or higher) or 0, if you wish.

 

Lee

Posted

because your a math major could you please explian to me what a factorial of a interger is? and when it's best used?

 
;  This is a programming example of a recursive function 
;  which calculates the factorial of an integer.
(defun factor (y)                
  (cond ((= 0 y) 1)
        (t  (* y (factor (1- y))))
  )
)
(defun C:FACT (/ x)
  (initget 7)     ;x must not be null, negative or zero
  (setq x (getint "Enter an integer: "))
  (factor (float x))
)

Posted

A Factorial is said integer multiplied by all of the integers beneath it (until 1):

 

i.e.

5! (5 factorial) = 5 x 4 x 3 x 2 x 1 = 120

 

4! (4 factorial) = 4 x 3 x 2 x 1 = 24

etc.

 

This is useful in many different applications - for example counting the number of ways you can order a set of n different objects is n!

 

Or in a binomial expansion of say, (1 + x)^n, factorials are used in the expressions for the coefficients:

 

1 + nx + (n(n-1)/2!)x^2 + (n(n-1)(n-2)/3!)*x^3 etc etc

 

For more on factorials, see here:

 

http://en.wikipedia.org/wiki/Factorial

 

For more on Binomial Expansions, see here:

http://en.wikipedia.org/wiki/Binomial_expansion

 

Hope this helps :)

 

Lee

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