VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Intersectwith - 3DFaces and 3DPolyline

7 REPLIES 7
Reply
Message 1 of 8
JohnAZ
827 Views, 7 Replies

Intersectwith - 3DFaces and 3DPolyline

I use AutoCAD 2002 + 2005 and want to intersect a 3DPolyline with several 3DFaces. What I care about are the coordinates of the point of intersection for external use.

I use the VBA-method "intersectwith" but do not get any results - although it should work according to the ActiveX and VBA Reference. Generally speaking after hours of testing: The method works for 2D objects but not for 3D objects.

Does anybody know a workaround? Thoughts, ideas? Is AutoCAD 2007 able to solve my problem? Or Autodesk Civil 3D 2006? The problem is of major importance to me and therefore all kinds of input is appreciated.

Context:
The above mentioned problem is part of a more complex issue which can be described in a few words! I use a digital 3D City model and want to step along a trajectory (3D Polyline) and check the horizontal distance to the right and left to the nearest building (3D Faces). Further, I need the height of the corresponding building. For better understanding I visualized the problem here: http://people.freenet.de/wammer/forums/cad.html

Thanks!
John
7 REPLIES 7
Message 2 of 8
Anonymous
in reply to: JohnAZ

I think here is a good starting point
how to do it:

http://astronomy.swin.edu.au/~pbourke/geometry/planeeq/

Fatty

~'J'~
Message 3 of 8
Anonymous
in reply to: JohnAZ

I can't write this on VBA for this moment, maybe with
lisp this will helps you too...
Copy code to Notepad, then save this code as ilf.lsp
Draw 3dfaces, draw lines by coordinates of 3d polyline, then
run this lisp. Just type ilf in command line

~~~~~~~~~~~~~~code begin
;; written by Fatty T.O.H.()2006
;; all rights removed
;; intersection line with 3dface
(defun group-by-num (lst num / ls ret)
(if (= (rem (length lst) num ) 0)
(progn
(setq ls nil)
(repeat (/ (length lst) num)
(repeat num (setq ls
(cons (car lst) ls)
lst (cdr lst)))
(setq ret (append ret (list (reverse ls)))
ls nil)))
)
ret
)
(defun c:ilf (/ a b c1 ipt p1 p2 p3 p4 p5)
(vl-load-com)
(if (not cal)
(arxload "geomcal.arx"))
(setq a (vlax-ename->vla-object
(car (entsel "\nSelect line :\n")))
b (vlax-ename->vla-object
(car (entsel "\nSelect 3dface:\n")))
ipt (vla-Intersectwith a b acextendnone))

(setq c1 (group-by-num(vlax-get b 'coordinates) 3 )
p1 (vlax-get a 'Startpoint)
p2 (vlax-get a 'Endpoint)
p3 (car c1)
p4 (cadr c1)
p5 (caddr c1))
(setq ipt (cal "ilp(p1,p2,p3,p4,p5)"))
(alert (strcat "Intersection point coordinates:\n\n"
"X= " (vl-princ-to-string (rtos (car ipt) 2 12)) "\n"
"Y= " (vl-princ-to-string (rtos (cadr ipt) 2 12)) "\n"
"Z= " (vl-princ-to-string (rtos (caddr ipt) 2 12))))
(princ)
)
(prompt "\n\t\t*** Type ILF to execute ***")
(princ)
code end~~~~~~~~~~~~~~~~~

Fatty

~'J'~
Message 4 of 8
JohnAZ
in reply to: JohnAZ

Thanks! Just as you said, it works with ordinary lines with x,y,z-coordinates and 3DFaces. (It even works with PolygonMesh!)
Question 1: I noticed that you use "geomcal.arx". Is there a chance to use this with VBA??? I do not feel too comfortable with lisp and would prefer to solve this in VBA!
Question 2: Does lisp work if you do not know what 3DFace or (many) 3DFaceS (!!!) actually intersect with a line. I am asking because I always get a result from your routine even if the line does not intersect with the 3DFace.
For your interest: I attached my VBA-solution so far. Running a 3DPolyline through a 3DFace, the color of the 3DFace changes (to show that they somehow intersect) but I do not get the point of intersection. Please read the 3 lines in the header of the dvb-file about how to run the routine and what to enter!
John
Message 5 of 8
Anonymous
in reply to: JohnAZ

Oh, my bad
My apologies, I have confused you, because of
function CAL returns a point of intersection of a line and a plane, to which belongs 3dface
Still working on it

Sorry

Fatty

~'J'~
Message 6 of 8
Anonymous
in reply to: JohnAZ

Hi John,
Try this way, but very rough I think...
See word wrap in the drawing

Fatty

~'J'~
Message 7 of 8
JohnAZ
in reply to: JohnAZ

Hi,
I could not open the sample.dwg in the zip-file. Is it because it is saved as ACAD2006 or even 2007? I use 2002. Please email me at johnazmann@yahoo.com
Thanks a bunch for your help so far! I will get back after I tested your sample.dwg.
John
Message 8 of 8
Anonymous
in reply to: JohnAZ

Ok, I will be change it on A2000

Fatty

~'J'~

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost