Jump to content
mihaibantas

Help ...move blocks vertically on polyline

Recommended Posts

mihaibantas

Hello everyone,

I'm facing a problem :oops:... I have a lot of blocks in the air that need to be connected two by two with a certain polyline.

 

I have a LISP code I've found on the net, I've modified the code, but the blocks do not fall vertically on polyline ... and I can not figure it out by doing the lisp code.

 

I attached the dwg file and the lisp code for example ... I remain deeply grateful for helping:D

Example code.dwg

MY_snapToObj.lsp

Share this post


Link to post
Share on other sites
eldon

The lisp code is finding the nearest point on the polyline, and not the vertical intersection with the polyline.

Share this post


Link to post
Share on other sites
zixuan203344
(defun c:snapToObj (/ c en posit pt pten ptobj pts_ss ss_len)	
 (princ "\nSelecteaza PolyLinia Terenului: ")
 (setq en (ssget "_:S+."))
 (princ "\nSelecteaza Blocurile Gard: ")
 (setq pts_ss (ssget (list (cons 0 "INSERT"))))
(setq ss_len (sslength pts_ss))
(setq c 0)
 (while (< c ss_len)
   (setq pten (ssname pts_ss c))
   (setq ptobj (vlax-ename->vla-object pten))
	(setq pt(vlax-get ptobj 'InsertionPoint))
	(setq posit(make_inters ptobj (vlax-ename->vla-object (ssname en 0))))		
   (vla-move ptobj (vlax-3d-point pt) (vlax-3d-point posit))
   (setq c (+ c 1))
)	
(princ)	
)
(defun make_inters(insert curve / curve_vla insert_vla instpt inters_co var xl xl_vla)
(if(equal (type insert) "VLA-OBJECT")
	(setq insert_vla(vlax-ename->vla-object insert))
	(setq insert_vla insert)
)
(if(equal (type curve) "VLA-OBJECT")
	(setq curve_vla(vlax-ename->vla-object curve))
)
(setq instpt(vlax-get insert_vla 'InsertionPoint))
(entmake (list '(0 . "XLINE") '(100 . "AcDbEntity") '(100 . "AcDbXline") (cons 10 instpt) (cons 11 '(0 -1 0))))
(setq xl(entlast))
(setq var(vla-IntersectWith curve_vla (setq xl_vla(vlax-ename->vla-object xl)) acExtendNone))
(setq inters_co(vlax-safearray->list (vlax-variant-value var)))
(vla-Delete xl_vla)
inters_co
)

Share this post


Link to post
Share on other sites
zixuan203344

sorry for this code,you can replace it by yourself

	(if([color="red"]not[/color](equal (type insert) "VLA-OBJECT"))
	(setq insert_vla(vlax-ename->vla-object insert))
	(setq insert_vla insert)
)
(if([color="red"]not[/color](equal (type curve) "VLA-OBJECT"))
	(setq curve_vla(vlax-ename->vla-object curve))
)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×