TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Amsterdammed on November 22, 2011, 08:10:48 AM
-
Hello,
I'm working on a program to define the make a section on each of the walls in our building we need to show. all fine as long as the walls (3solids) are parallel to the usc, i use the bounding box.
Can i define a ucs by a 3dsolid with lisp (through "face" maybe, but how to select by lisp)
and will the bounding box give the correct "footprint of the wall when in object ucs with the wall?
Thanks
-
http://www.theswamp.org/index.php?topic=32179.0 (http://www.theswamp.org/index.php?topic=32179.0)
-
Lee,
i get an error when i try to load obb arx. And honestly, i was hoping for a solution in vlisp.
-
Hi,
It may be (very) difficult to get 3d solids data in plain (Visual) LISP.
If you're using A2009 or later, you can try the .NET defined gc-Brep (http://www.theswamp.org/index.php?topic=39278.msg445148#msg445148) Lisp function.
-
gile
thanks, but i have no clue how to use that?
what do have to load and how do i start it?
Thanks
Bernd
-
Through here, i used face selection, hope it helps:
http://www.cadtutor.net/forum/showthread.php?43375-3d-Objects-Volume-LISP-required
-
Lee,
i get an error when i try to load obb arx. And honestly, i was hoping for a solution in vlisp.
What AutoCAD version do you use?
If i get some time, will try to update my project - But looks like what Gile/WizMan did (open-source) already works - so please give that a try.
-
This may help or give you ideas, or not, maybe. works for me (sometimes)
This is how I work out length of a beam (drawn as a 3dsolid).
My beam function stores 2 points along length of beam as xdata.
The length function retrieves the 2 points (pt3 and pt4) and does it's thing as
shown. The real clever stuff is done by the functions written by THESWAMP lispmasters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:test ()
;;;
(setq StlEnt (car (entsel "\nPick beam")))
(setq pt3 '(471.3056 380.3116 0.0000))
(setq pt4 '(221.3056 813.3243 0.0000))
;;;
(command ".ucs" "")
(command ".ucs" "3" pt4 pt3 (polar pt3 (+ (Dmdtr 90) (angle pt3 pt4)) 10))
(setq boxlst (ucs-bbox StlEnt))
(setq xlst (mapcar '(lambda (pt) (car pt)) boxlst))
(setq x_max (apply 'max xlst))
(setq x_min (apply 'min xlst))
(setq len (- x_max x_min))
(command ".ucs" "p")
(command ".ucs" "p")
len
)
;;;=============================================================================
(defun DMDtr (Y) (* pi (/ y 180.0)))
;;;=============================================================================
;; Doug C. Broad, Jr.
;; can be used with vla-transformby to
;; transform objects from the UCS to the WCS
;; transform objects from the WCS to the UCS
(defun UCS2WCSMatrix ()
(vlax-tmatrix
(append
(mapcar
'(lambda (vector origin)
(append (trans vector 1 0 t) (list origin))
)
(list '(1 0 0) '(0 1 0) '(0 0 1))
(trans '(0 0 0) 0 1)
)
(list '(0 0 0 1))
)
)
)
(defun WCS2UCSMatrix ()
(vlax-tmatrix
(append
(mapcar
'(lambda (vector origin)
(append (trans vector 0 1 t) (list origin))
)
(list '(1 0 0) '(0 1 0) '(0 0 1))
(trans '(0 0 0) 1 0)
)
(list '(0 0 0 1))
)
)
)
;; UCS-BBOX (gile)
;; Returns the UCS coordinates of the object bounding box about UCS
;;
;; Argument
;; obj : a graphical object (ename or vla-object)
;;
;; Return
;; a list of left lower point and right upper point UCS coordinates
(defun ucs-bbox (obj / space bb minpoint maxpoint line lst)
(vl-load-com)
(and (= (type obj) 'ENAME)
(setq obj (vlax-ename->vla-object obj))
)
(vla-TransformBy obj (UCS2WCSMatrix))
(setq bb (vla-getboundingbox obj 'minpoint 'maxpoint))
(vla-TransformBy obj (WCS2UCSMatrix))
(list
(vlax-safearray->list minpoint)
(vlax-safearray->list maxpoint)
)
)
[code]
-
The real problem is that i want to do this with a selection set, so multiple items. if i had only a single one, i had no problem, set UCS to face of the solid and had my direction for the bounding box, or not?
but how can i do this without picking the solid???
-
If you store orientation points in XDATA in your 3dsolids,
(setq SS1 (ssget "X" (list (list -3 (list appnam)))))
will create a selection set of all the objects with your XDATA. 'appnam' is the XDATA application name.
That is how I do it.
-
Sure,
but i need to store them first.
I situation is that we get 3d solids out of a revit model form our builder and then we work with that. all our needed holes in those walls i wanted to find automated. Since we get an permanent update stream i can not store in the solids because they a suspect to update.
-
I posted an ActiveX based method (VBA) here:
http://www.theswamp.org/index.php?topic=21524
The tester routine, “SolidDims_Main()”, ask the user to select a solid but the methodology is not based on a selected face (In other words, it could be set up for Selection Sets).
-
Would the solids in question always be set upright? It seems like that would be the case with walls.
If so, then the routine I just linked is unnecessarily complicated. It was set up to coordinated extrusion with any arbitrary orientation.