alex198617 Posted April 8, 2013 Posted April 8, 2013 (edited) Hi Friends I don't know where to begin i'm planning fiber optics with autocad, i got problem with deadline (in Attachments i attach file) - there is city map with telecommunication, wells, telecommunication Pole, House, Fiber optics, box whit splitters. 8 House is 1 ring, 1 spliteri serving 8 house (1/8 spliteri) 8 houses encircling the ring is very difficult and takes a lot of time I want something simple script that would be able to unite in a ring of 8 homes The script for the map to be ready for the points which should be linked to the spliteri, spliteri be attached to a telephone pole. i don't know much English to Explained more better The forum could not find anything like this and that is why I have created a new post If there is a similar post do not ban me admin FTTH-Tbilisi-sanzona-v2.dwg Edited April 9, 2013 by alex198617 mistake Quote
BIGAL Posted April 9, 2013 Posted April 9, 2013 Some suggestions not code 1 insert ring 2 pick in clock wise direction next 8 points a line will draw to correct link to ring Ok some more insert ring get co-ords of centre of ring work out next 8 pts the join pt to the ring A start (seqt inspt (getpoint "\nPick ring point")) (Command "_insert" "Ring" inspt 1 1 0) (setq pt1 (polar inspt 3.141593 3.519)) ; polar from pt angle distance (seqt pt2 (polar inspt 2.703917 3.519)) ;pt3-pt8 ; DO OTHERS ANGLE IN RADIANS ; do 8 times (setq pick1 (getpoint "\nPick point)) (command "line" pickpt pt1 "") (setq pick1 (getpoint "\nPick point)) (command "line" pickpt pt2 "") (princ "wow all done") (princ) Quote
pBe Posted April 9, 2013 Posted April 9, 2013 (edited) (defun c:demo (/ p pts pt bn) (setq angs '(3.14159 2.70392 2.27876 1.84008 1.31112 0.871444 0.443503 0.0)) (if (and (tblsearch "BLOCK" "001.SPLICE-1-8+Box") (tblsearch "BLOCK" "001.SPLICE-1-4+Box") (setq p (getpoint (strcat "\nPick House nos. " (itoa (setq n 1))))) (setq pts (cons p pts)) ) (progn (while (and (< (length pts) (setq p_ (getpoint p (strcat "\nPick House nos. " (itoa (setq n (1+ n))) " <Enter when Done>" ) ) ) ) (setq pts (cons p_ pts) p p_ ) ) (while (eq 5 (car (setq gr (grread T 15 0)))) (setq pt (trans (cadr gr) 1 0)) (redraw) (foreach px pts (grdraw (trans px 0 1) (cadr gr) 1 -1) ) ) (redraw) (if (<= 1 (length pts) 4) (setq bn "001.SPLICE-1-4+Box" angs '(2.27876 1.84008 1.31112 0.871444)) ) (vlax-invoke (vlax-get (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object) ) ) 'Block ) 'InsertBlock pt (if bn bn "001.SPLICE-1-8+Box") 1 1 1 0 ) (mapcar '(lambda (j k) (entmakex (list (cons 0 "LINE") (cons 10 j) (cons 11 (polar pt k 3.5125)) ) ) ) (reverse pts) angs ) ) ) (princ) ) Same as Bigals' instructions, Clockwise direction. Also i redefine the block "001.SPLICE-1-8+Box" to make it symmetrical. DEMO FILE_4&8.dwg Edited April 9, 2013 by pBe Modify to accept splice 4 box Quote
pBe Posted April 9, 2013 Posted April 9, 2013 (edited) If you're wanting to select the pole instead MODIFIED TO CREATE LWPOLYLINE (defun c:demo2 (/ p pts pt bn) (vl-load-com) (setq space (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object)))) (setq angs '(3.14159 2.70392 2.27876 1.84008 1.31112 0.871444 0.443503 0.0)) (if (and (tblsearch "BLOCK" "001.SPLICE-1-8+Box") (tblsearch "BLOCK" "001.SPLICE-1-4+Box") (setq p (getpoint (strcat "\nPick House nos. " (itoa (setq n 1))))) (setq pts (cons p pts)) (progn (while (and (< (length pts) (setq p_ (getpoint p (strcat "\nPick House nos. " (itoa (setq n (1+ n))) " <Enter when Done>" ) ) ) ) (setq pts (cons p_ pts) p p_ ) ) T ) (setq pole (ssget "_:S:E" '((0 . "INSERT") (2 . "telasis bodzi")))) ) (progn (setq pt (cdr (assoc 10 (entget (ssname pole 0))))) (if (<= 1 (length pts) 4) (setq bn "001.SPLICE-1-4+Box" angs '(2.27876 1.84008 1.31112 0.871444)) ) (vlax-invoke space 'InsertBlock pt (if bn bn "001.SPLICE-1-8+Box") 1 1 1 0 ) (mapcar '(lambda (j k) (setq p2 (polar pt k 3.5125)) (vlax-invoke space 'Addlightweightpolyline (list (car j) (cadr j) (car p2) (cadr p2)) ) ) (reverse pts) angs ) ) ) (princ) ) Now if you want to add VERTICES on the created plines use this: [not sure about the author] (defun c:adv (/ ent i nlst obj p pt x) (vl-load-com) (while (setq ent (entsel "\nSelect point on polyline to add vertex: ")) (if (and ent (= (cdr (assoc 0 (entget (car ent)))) "LWPOLYLINE")) (progn (setq i (fix (vlax-curve-getparamatpoint (car ent) (setq p (vlax-curve-getclosestpointto (car ent) (cadr ent))) ) ) obj (vlax-ename->vla-object (car ent)) pt (vlax-curve-getpointatparam (car ent) i) nlst nil ) (mapcar '(lambda (x) (if (equal x (list 10 (car pt) (cadr pt)) 0.0001) (setq nlst (cons x nlst) nlst (cons (list 10 (car p) (cadr p)) nlst) ) (setq nlst (cons x nlst)) ) ) (entget (car ent)) ) (entmod (reverse nlst)) (entupd (car ent)) (sssetfirst nil (ssadd (car ent))) ) ) ) (sssetfirst nil) (princ) ) Then stretch the vertex to suit your needs HTH Edited April 9, 2013 by pBe Quote
alex198617 Posted April 9, 2013 Author Posted April 9, 2013 thank you so much for codes #pBe and #BIGAL the idea/code work perfect "demo2" i test it and it's works tomorrow i'll try to see who it will cut time for planning just one edit for "demo2" > (setq angs '(3.14159 2.70392 2.27876 1.84008 1.31112 0.871444 0.443503 0.0)) what will be the number for center of object (block>) ? i tried 0.0 but it gose somewhere else Quote
Tharwat Posted April 9, 2013 Posted April 9, 2013 pBe , why did you convert the entity to vla-object in your second routine ? Quote
pBe Posted April 10, 2013 Posted April 10, 2013 just one edit for "demo2" > (setq angs '(3.14159 2.70392 2.27876 1.84008 1.31112 0.871444 0.443503 0.0)) what will be the number for center of object (block>) ? i tried 0.0 but it gose somewhere else The values on angs variable are angles and not points. why do you need the center point of the block? [or insertion point?] anyhoo that will be variable pt pBe , why did you convert the entity to vla-object in your second routine ? ....[not sure about the author].... Quote
alex198617 Posted April 10, 2013 Author Posted April 10, 2013 pBe what i mean is this and it will be more better with this Quote
pBe Posted April 10, 2013 Posted April 10, 2013 One: if you pick the point at clockwise direction the lines wont cross Two: what you need is a lot less code (defun c:demo3 (/ p pts pt bn) (vl-load-com) (if (and (tblsearch "BLOCK" "001.SPLICE-1-8+Box") (tblsearch "BLOCK" "001.SPLICE-1-4+Box") (setq p (getpoint (strcat "\nPick House nos. " (itoa (setq n 1))))) (setq pts (cons p pts)) (progn (while (and (< (length pts) (setq p_ (getpoint p (strcat "\nPick House nos. " (itoa (setq n (1+ n))) " <Enter when Done>" ) ) ) ) (setq pts (cons p_ pts) p p_ ) ) T ) (setq pole (ssget "_:S:E" '((0 . "INSERT") (2 . "telasis bodzi")))) ) (progn (setq pt (cdr (assoc 10 (entget (ssname pole 0))))) (if (<= 1 (length pts) 4) (setq bn "001.SPLICE-1-4+Box" ) ) (vlax-invoke (vla-get-modelspace (vla-get-activedocument (vlax-get-acad-object))) 'InsertBlock pt (if bn bn "001.SPLICE-1-8+Box" ) 1 1 1 0 ) (foreach p pts (entmakex (append (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 90 2) (cons 70 0) ) (mapcar (function (lambda (p) (cons 10 p))) (list pt p)) ) ) ) ) ) (princ) ) Now the direction for pick points is irrelevant. Quote
alex198617 Posted April 10, 2013 Author Posted April 10, 2013 thank you my friend now i'll try make with this code Quote
Tharwat Posted April 10, 2013 Posted April 10, 2013 ....[not sure about the author].... Are not you the author ? Quote
alex198617 Posted April 11, 2013 Author Posted April 11, 2013 this script works but i have question :/ is it possibly to invert this scrip ? what i mean is to click on "Telasi bodzi" block and he connect with line near by 8 house points ? Quote
pBe Posted April 11, 2013 Posted April 11, 2013 Are not you the author ? Not the one you are referring to [c:adv] this script works but i have question :/ is it possibly to invert this scrip ? what i mean is to click on "Telasi bodzi" block and he connect with line near by 8 house points ? Without indicating the house location via pick point? or even selecting the "RED" circles? Quote
alex198617 Posted April 11, 2013 Author Posted April 11, 2013 I mean, would himself be able to identify nearby buildings. look pBe i'm very pleased that you help me the script is for 2nd task the 1st is that i draw polygon around 8 houses and than is 2nd task (with your help ) so if it will be possible to make my 2 task in one like click on block and connect near by 8 house and so on Quote
pBe Posted April 11, 2013 Posted April 11, 2013 Not sure i understand what that mean alex198617 Quote
alex198617 Posted April 11, 2013 Author Posted April 11, 2013 Ok never mined thanks for your help my Friend Quote
pBe Posted April 11, 2013 Posted April 11, 2013 Ok never mined thanks for your help my Friend show an image like you did before Quote
BIGAL Posted April 12, 2013 Posted April 12, 2013 If I understand you just pick 8 house with pline shape, lots of problems the houses will be returned in the created order not as you see them. Using a select within polygon would give a list of the selected houses but you would need an additional routine to rearrange the list into lower left through to lower right. Maybe with a pick approx center of houses so link block could go anywhere. Pbe what do you think. Quote
alex198617 Posted April 18, 2013 Author Posted April 18, 2013 i finish my one month job in 3 days, thanks to you pBe Quote
Noel272287 Posted January 11, 2021 Posted January 11, 2021 Hi there, I came across this conversation and was wondering does this lisp still work? 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.