• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

how to invoke a lisp function within file lisp

  • Thread starter Thread starter som
  • Start date Start date

som

Guest
hello to all, thanks to your help I managed to write a little code that fits my situation and that allows me to select a part of a dwg to turn it into jpeg by plotter.

Now I should move some texts that I would find myself out of the selected window, so I wrote the translatest function that I can use by autocad but not on the other lisp function, what am I wrong? !

Thanks again
Code:
(defun c:puntiassi ()
(setvar "cmdecho" 0)
(setq gr(ssget "x" ( (0 . "line") (8 . "assi"))))
(if gr)
(setq kk 0)
(setq xlimitedestro 0)
(setq xlimitesinistro 0)
(setq ylimitesup 0)
(setq ylimiteinf 0)
(repeat (sslength gr)
(setq point(entget(sname gr kk)))
(setq pnew)
(car(cdr(assoc 10 point)));
(cdr(cdr(assoc 10 point)));
(cadr(cdr(assoc 10 point)));
)
(princ "\n")
(if = kk 1)
(setq ylimitesup (cdr(assoc 10 point))))
)
(if = kk 2)
(setq ylimiteinf (cdr(cdr(assoc 10 point))))
)
(if = kk 3)
(setq xlimitedestro (car(cdr(assoc 10 point))))
)
(if = kk 4)
(setq xlimitesinistro (car(cdr(assoc 10 point)))))
)
(princ (car(cdr(assoc 10 point))))
;(seq point(subst (cons 10 pnew) (assoc 10 point)))
;(included)
(setq kk(+ kk 1))
)
)
(princ "\n limitedestro x : ")
(princ xlimitedestro)
(princ "\n limitless x : ")
(princ xlimitesinistro)
(princ "\n limitsup y : ")
(princ ylimitesup)
(princ "\n limitinf y : ")
(princ ylimiteinf)


(setq p3 (list xlimitesinistro ylimiteinf)); left bottom
(setq p4 (list xlimitedestro ylimitesup)); upper right
(princ "\n")
(princ "p3")
(princ p3)
(princ "p4")
(princ p4)

 [COLOR="Red"]  (command "traslatesto" 300.0 10.0 )[/COLOR];(command "300")
;(command "10")

(command "_plot" "yes" "model" "jpeg.pc3"" "horizontal" "no" "window"
p3 p4 "suitable" "center" "yes" "acad.ctb" "no" "hidden" "no" "yes" "yes" "yes")
; after hidden I have the file name
)
(defunc c:translatesto(/ traslx trasly)
(setq traslx 300.0)
(setq trasly 10.0)
(setq traslx (getint "\ninseri traslation x:"))
(setq trasly (getint "\ninserire translation y:"))
(setvar "cmdecho" 0)
(setq gr(ssget "x" ((8 . "text")))))
(if gr)
(setq kk 0)
;(seq translation 300)
;(seq traslazioney 10)
(repeat (sslength gr)
(setq point(entget(sname gr kk)))
(setq oldx (car(cdr(assoc 10 point)))))
(setq oldy (cadr(cdr(assoc 10 point))))
(setq newx (- oldx traslx)
(setq newy (- oldy trasly)

(setq pnew)
newx; x
newy, y
(cdr(cdr(assoc 10 point)));
)
(princ "\n")
(princ oldy)
(setq point(subst (cons 10 pnew) (assoc 10 point)))
(entmod point)
(setq kk(+ kk 1))
)
)
)
to see if it works I was trying to directly insert numbers.. then I will have to enter a value that depends on the limits of the window.
 
Okay, I get it. I was wrong because I defined the function as a command!
Code:
(fun traslatesto(traslx trasly)
...
Now I can invoke her!
 
not for that but because you do not call a command via (command "translatesto") but with the syntax (c:translatesto).

bye
 
Good morning, everyone.
I wanted to know if someone knows how to use the entsel function using a variable (coordinated) instead of the selection required to the command.
example code used :
(setq ent (entget (entsel)))
(setq list_attributes nil)
(if (= (cdr) "insert")
(progn)
(setq ogg (cdr))
(setq ent1 (entnext ogg)
(if ent)
(progn)
(setq type (cdr (assoc 0 (entget ent1))))
(while (= type "attrib")
(setq value_attributed (cdr (assoc 1))))
(setq list_attributed (append (value_attributed list) list_attributed))
(setq ent1 (entnext ent1))
(setq type (cdr (assoc 0 (entget ent1))))
)
)
)
)
)
 
Good morning, everyone.
I wanted to know if someone knows how to use the entsel function using a variable (coordinated) instead of the selection required to the command.
example code used :
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
with entsel you can not, you have to use nentselp (ntselp [msg_richiesta] [pt])
provides functionality similar to that of the function nentsel without the user input necessary.

already seen that list :rolleyes:
 
I'm sorry I mentioned your code.
You don't have to apologize. the problem is the inexorable decrease of my 12 remaining neurons, he thinks I glued it into the vlisp editor to try it:biggrin:, only after I remembered. . .

By the way, that code is mine only partially.
 
you know taken from nervousness and the desire to find a way to make things work... I clinged to the first code I found.... very useful for a beginner.
Thanks again
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top