Hi everyone, I'm trying to make a lisp that would help me lots in work, I'm not very good at this so I advance slowly by trial and error, but now I'm stuck...
Please if someone can take a look at the code. After the "foreach" function the points that was saved whit the entlast (ptoelev2, ptocielo2,ptopiso2) the "rotate" and "move" functions won't recognize that variables....
(defun C:xgiro(/ angulo prim elev linea obj1 obj2)
(command "_filedia" "0" )
(command "_color" "_t" "255,0,0" )
(setq angulo (getstring "\nAngulo de giro: "))
(setq elev (car (entsel "\nLínea de elevación: ")))
(setq cielo (car (entsel "\n Polilínea de contracielo: ")))
(setq piso (car (entsel "\n Polilínea de piso: ")))
(setq elevgiro (car (entsel "\nLínea de elevación con giro: ")))
(while
(setq prim (getpoint "\nPunto en la planta de la obra: "))
(command "_line" prim "@10<90" "")
(setq linea (entlast))
(command "_copy" linea "" "0,0,0" "0,0,0")
(setq lineagiro (entlast))
(command "_rotate" lineagiro "" prim angulo)
(setq ptoelev (foreach pnt (LM:Intersections (vlax-ename->vla-object linea) (vlax-ename->vla-object elev) acextendthisentity)
(entmake (list '(0 . "POINT") (cons 10 pnt)))
))
(setq ptocielo (foreach pnt (LM:Intersections (vlax-ename->vla-object linea) (vlax-ename->vla-object cielo) acextendthisentity)
(entmake (list '(0 . "POINT") (cons 10 pnt)))
))
(setq ptopiso (foreach pnt (LM:Intersections (vlax-ename->vla-object linea) (vlax-ename->vla-object piso) acextendthisentity)
(entmake (list '(0 . "POINT") (cons 10 pnt)))
))
(command "_point" ptoelev "")
(setq ptoelev2 (entlast))
(command "_point" ptocielo "")
(setq ptocielo2 (entlast))
(command "_point" ptopiso "")
(setq ptopiso2 (entlast))
(foreach pnt (LM:Intersections (vlax-ename->vla-object lineagiro) (vlax-ename->vla-object elevgiro) acextendthisentity)
(entmake (list '(0 . "POINT") (cons 10 pnt)))
)
(setq ptoelevgiro (entlast))
(command "_rotate" ptoelev2 ptocielo2 ptopiso2 "" ptoelev angulo )
(command "_move" ptoelev2 ptocielo2 ptopiso2 "" ptoelev ptoelevgiro)
(princ)
); end while
(command "_color" "_BYLAYER" )
(command "_filedia" "1" )
(princ)
)
(vl-load-com)(princ)
(defun LM:Intersections ( obj1 obj2 mode / l r )
(setq l (vlax-invoke obj1 'intersectwith obj2 mode))
(repeat (/ (length l) 3)
(setq r (cons (list (car l) (cadr l) (caddr l)) r)
l (cdddr l)
)
)
(reverse r)
)