mihaibantas Posted April 3, 2018 Posted April 3, 2018 Hello everyone, I'm facing a problem ... 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 Quote
eldon Posted April 3, 2018 Posted April 3, 2018 The lisp code is finding the nearest point on the polyline, and not the vertical intersection with the polyline. Quote
DGRL Posted April 3, 2018 Posted April 3, 2018 Maybe this is of help https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-AutoLISP/files/GUID-23A1B8CE-9FF5-482C-AF32-3EE48784B905-htm.html Quote
zixuan203344 Posted April 3, 2018 Posted April 3, 2018 (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 ) Quote
zixuan203344 Posted April 3, 2018 Posted April 3, 2018 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)) ) Quote
Recommended Posts
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.