Add Vertex on 3dpoly

Add Vertex on 3dpoly

neam
Collaborator Collaborator
2,136 Views
14 Replies
Message 1 of 15

Add Vertex on 3dpoly

neam
Collaborator
Collaborator

Hi

I want to create vertex at the intersection of the main 3dpolyline with the yellow 3dpolylines (or lines) on the main 3dpolyline.

0 Likes
Accepted solutions (1)
2,137 Views
14 Replies
Replies (14)
Message 2 of 15

john.uhden
Mentor
Mentor

@neam 

See if the attached 3DEDIT.lsp helps you.

If you want to pick up the elevation of the "other" 3D then use _appint and select the "other" first.

Same goes for intersecting with any "other" entity.

John F. Uhden

0 Likes
Message 3 of 15

hak_vz
Advisor
Advisor

--

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 4 of 15

neam
Collaborator
Collaborator

Thank you for your attention.

I want to select the main 3dpolyline first and then select the other 3dpolylines (or 3d lines).

then add vertex on main 3dpolyline at the intersection.

0 Likes
Message 5 of 15

neam
Collaborator
Collaborator

Unfortunately, I did not get the desired answer.

Thanks for the code sent.
Unfortunately, the submitted code does not work properly.

 

0 Likes
Message 6 of 15

marko_ribar
Advisor
Advisor

AFAIK, You can only re make new 3d polyline and replace old one with altered modifications...

Perhaps you could try to find something better to avoid loosing possible data attachments to reference old entity (3d poly), or store them before you do replacement and then put stored data back to new one... But like I said, AFAIK, you can't add Vertex and keep old 3d poly handle - only thing I see is replace and remove which is wrong IMHO or perhaps IEHO (In Everyones Humble Opinions)...

Marko Ribar, d.i.a. (graduated engineer of architecture)
Message 7 of 15

hosneyalaa
Advisor
Advisor

hi

It is possible through .net , it will be easier
For the intersection of different heights

 

 

Message 8 of 15

hak_vz
Advisor
Advisor

After posting my code I have noticed that you request something else. I'll modify my code and post it later today.

I've made my code to work on single segment and since it is to complex to work with multiple sections at once.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 9 of 15

neam
Collaborator
Collaborator

Thank you very much for your attention.

0 Likes
Message 10 of 15

hak_vz
Advisor
Advisor
Accepted solution

@neam  Check if this is what you asked for.

(defun c:foo 
	( /
		pick_3dpoly take take2 mappend mklist flatten 3dpo coord2d coords ycoords ycoords ss i j int_list
		p1 p2 p3p p4 ip mp np p12d p22d a b newcoords
	)
	(defun pick_3dpoly (msg)
		(setq e (entsel msg))
		(if (and (not e) (= (getvar 'Errno) 7)) (pick_3dpoly msg) (car e))
	)
	(defun take (amount lst / ret)(repeat amount (setq ret (cons (car lst) (take (1- amount) (cdr lst))))))
	(defun take2 (lst) (take 2 lst))
	(defun pointlist3d (lst / ret) (while lst (setq	ret (cons (take 3 lst) ret) lst (cdddr lst))) (reverse ret))
	(defun mappend (fn lst)(apply 'append (mapcar fn lst)))
	(defun mklist (x) (if (listp x) x (list x)))
	(defun flatten (exp)(mappend 'mklist exp))
	(defun nthcdr (arg lst / ret) (setq ret lst) (if (> arg 0)(repeat arg (setq ret (cdr ret))) (setq ret ret)) ret)
	(setq 
		3dpo (vlax-ename->vla-object (pick_3dpoly "\nSelect main 3dpolyline >"))
		coords (pointlist3d(vlax-get 3dpo 'Coordinates))
		coord2d (mapcar 'take2 coords)
	)
	(princ "\nSelect yelow 3dpolyline to add vertex at intersction >")
	(setq	
		ss (ssget "_+.:E:S" '((0 . "POLYLINE")(100 . "AcDb3dPolyline") (62 . 2)))
		i -1
		int_list nil
	)
	(cond 
		((and ss)
			(while (< (setq i (1+ i)) (sslength ss))
				(setq eo (vlax-ename->vla-object(ssname ss i)))
				(setq ycoords (pointlist3d(vlax-get eo 'Coordinates)))
				(setq ycoords2d (mapcar 'take2 ycoords))
				(setq p1 (car ycoords))
				(setq p2 (cadr ycoords))
				(setq p12d (take 2 (car ycoords2d)))
				(setq p22d (take 2 (cadr ycoords2d)))
				(setq j -1)
					(while (< (setq j (1+ j))(1-(length coord2d)))
						(setq 
							p3 (nth j coord2d)
							p4 (nth (1+ j) coord2d)
						)
						(cond 
							((and(setq ip (inters p12d p22d p3 p4 T)))
								(setq ip (append ip (list 0)))
								(setq mp (mapcar '+ ip (list 0 0 3000)))
								(setq np (inters p1 p2 ip mp nil))
								(setq a (flatten (take (1+ j) coords)))
								(setq b (flatten(nthcdr (1+ j) coords)))
								(setq newcoords (append a np))
								(setq newcoords (append newcoords b))
								(setq newcoords (flatten newcoords))
								(princ (strcat"\nZ at intersection is " (rtos (last np) 2 3)))
							)
						)
					)
					(vlax-put 3dpo 'coordinates newcoords)
			)
		)
	)
	(princ)	
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 11 of 15

neam
Collaborator
Collaborator

Excellent, accurate and beautiful.
Thank you very much.
Just an extra request Of course with apologies :
Is it possible to select the all yellow lines together (Or do not exit the command and you can select the next line) ?

0 Likes
Message 12 of 15

hak_vz
Advisor
Advisor

@neam wrote:

Is it possible to select the all yellow lines together (Or do not exit the command and you can select the next line) ?


I'll work on it as soon as I catch some free time.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 13 of 15

neam
Collaborator
Collaborator

Of course, with my little familiarity with Lisp, I changed your code a bit.
Thanks for checking it out.

0 Likes
Message 14 of 15

marko_ribar
Advisor
Advisor

@neam 

What would you think if someone is in stupid task to take another picture of selfy of anyone...

I don't know your goal or objective of topic and beside that, IMHO, I imagine Michelangelo and Leonardo had just slightly better artistic personal obligations...

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 15 of 15

neam
Collaborator
Collaborator

Dear Marko
I have used your posts many times.
In some cases, you directly solved the problem posted by me.
And I am aware of your abilities.
I think the reason for this problem is my poor expression in English.
For further explanation, I must say that we went to the site of a dam and
mapped the access roads and berms on the body of the dam and entered it in the AutoCAD code.
And we needed to have many cross sections of the dam body perpendicular to the dam crown.
Finally, thank you again hak_vz and I apologize to you.

0 Likes