Jump to content

Help ...move blocks vertically on polyline


mihaibantas

Recommended Posts

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

Link to comment
Share on other sites

(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
)

Link to comment
Share on other sites

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))
)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...