What's up guys,
I have a routine that generates the cross sections along a reference line. I would like the created objects (regions) to be only temporary and disappear when changing the view back to plan.
I have never used grvecs and have no idea how to make the change.
;; Project Point onto Line - Lee Mac
;; Projects pt onto the line defined by p1,p2
(defun LM:projectpointtoline ( pt p1 p2 / v1 e )
(if (setq v1 (vx1 (mapcar '- p2 p1)))
(mapcar '+ p1 (vxs v1 (vxv (mapcar '- pt p1) v1)))
)
)
;; Vector x Scalar - Lee Mac
;; Args: v - vector in R^n, s - real scalar
(defun vxs ( v s )
(mapcar '(lambda ( n ) (* n s)) v)
)
;; Vector Dot Product - Lee Mac
;; Args: u,v - vectors in R^n
(defun vxv ( u v )
(apply '+ (mapcar '* u v))
)
;; Unit Vector - Lee Mac
;; Args: v - vector in R^2 or R^3
(defun vx1 ( v )
( (lambda ( n ) (if (equal 0.0 n 1e-10) nil (mapcar '/ v (list n n n))))
(distance '(0.0 0.0 0.0) v)
)
)
(defun c:xsec ( / e p p1 p2 p3 p4 pt1 pt2 q bl obj obje)
(vl-load-com)
(setvar "UserI1" (getvar "OSMode"))
(setvar 'osmode 0)
(prompt "\nSelecciona Solids: ")
(setq objs (ssget '((0 . "3DSOLID"))))
(if (and (setq e (car (entsel "\nSelect line: ")))
(setq obje (vlax-ename->vla-object e))
(= "LINE" (cdr (assoc 0 (setq e (entget e)))))
(setq p (getpoint "\nSpecify view point: "))
)
(if (setq q (LM:projectpointtoline (trans p 1 0) (cdr (assoc 10 e)) (cdr (assoc 11 e))))
(entmake (list '(0 . "POINT") (cons 10 q)))
(princ "\nZero length line.")
)
)
(setq lyr "seccion-transversal")
(vl-cmdf "Layer" "M" lyr "C" "white" "" "")
(setvar "CLAYER" lyr)
(setq p3 (vlax-curve-getendpoint obje))
(setq p4 (vlax-curve-getstartpoint obje))
(vl-cmdf "_point" p3)
(setq p1 (entlast))
(vl-cmdf "_move" p1 "" "_D" "0,0,1")
(setq pt1 (cdr (assoc 10 (entget (entlast)))));get coord
(setq y -1)
(repeat (sslength objs)
(princ "good")
(setq y (1+ y))
(setq obj (ssname objs y))
(setq objv (vlax-ename->vla-object obj))
(setq layername (vla-get-layer objv))
(vl-cmdf "_section" obj "" p3 p4 pt1)
(setq objr (ssget "X" (list '(0 . "REGION")
(cons 8 lyr)
) ;_ end of list
)
);
(vl-cmdf "_chprop" objr "" "Layer" layername "")
);end repeat
(vl-cmdf "_erase" p1 "")
(vl-cmdf "dview" "" "_PO" q p "_CL" "_F" "0.1" "_CL" "_B" "-0.1" "")
(vl-cmdf "_zoom" "_E")
(setvar "OSMode" (getvar "UserI1"))
(princ)
)