Hassan95 Posted June 25, 2023 Posted June 25, 2023 (edited) Is anyone here can help me. I cam across this. Conversation. It's very helpful. Can I show you my ftth example so anyone can develop a lisp to save me i tried chat-gbt and it gave me (defun c:ftth () (setq radius 0) (setq cabinet-capacity 0) ; Prompt the user for the radius and capacity (prompt "\nEnter the radius for the cabinet boundary (250 or 500): ") (setq radius (getreal)) (prompt "\nEnter the capacity of each cabinet: ") (setq cabinet-capacity (getint)) ; Define the function to create FTTH cabinets (defun create-cabinet (x y num) (setq quantity (* cabinet-capacity num)) (command "circle" x y radius) (command "text" (list (+ x radius) (+ y radius)) (strcat "Cabinet " (itoa num))) (list num quantity) ) ; Define the function to draw polyline (defun draw-polyline (start end) (setq old-layer (getvar "clayer")) (setq layer-name (cdr (assoc 8 (entget start)))) (setq color (cdr (assoc 62 (entget start)))) (setq polyline (entmakex (list '(0 . "LWPOLYLINE") '(8 . layer-name) '(62 . color) '(10 . (car (cdr (assoc 10 (entget start)))))))) (setq vertex-list (list (cdr (assoc 10 (entget start))) (cdr (assoc 10 (entget end)))))) (command "pedit" polyline "" "M" vertex-list "") (setvar "clayer" old-layer) ) ; Get user input for cabinet positions (setq p1 (getpoint "\nEnter the first cabinet position: ")) (setq p2 (getpoint "\nEnter the second cabinet position: ")) ; Calculate the center point of the cabinet boundary (setq center-point (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))) ; Calculate the distance from the center point to the cabinet positions (setq distance (distance center-point p1)) ; Create the cabinet boundary (command "circle" center-point distance) ; Create cabinets within the boundary (setq angle-step (/ (* 2 pi) cabinet-capacity)) (setq current-angle 0) (setq cabinet-data '()) (repeat cabinet-capacity (setq x (polar center-point current-angle distance)) (setq y (+ (cadr x) (cadr center-point))) (setq x (+ (car x) (car center-point))) (setq result (create-cabinet x y (+ 1 cabinet-data-length))) (setq cabinet-data (cons result cabinet-data)) (setq current-angle (+ current-angle angle-step)) ) ; Output the cabinet data (setq cabinet-data-length (length cabinet-data)) (setq table (tblnext "TABLE" 1)) (setq row (tbladd table)) (tblset row '("Cabinet Number" "Quantity")) (repeat cabinet-data-length (setq item (nth (- cabinet-data-length 1) cabinet-data)) (setq cabinet-number (nth 0 item)) (setq quantity (nth 1 item)) (setq row (tbladd table)) (tblset row (list (strcat "Cabinet " (itoa cabinet-number)) quantity)) (setq cabinet-data-length (- cabinet-data-length 1)) ) (tblout table) ; Draw polyline from every box or termination point to the cabinet (setq boxes '()) (setq terminations '()) (while (setq ent (car (entsel "\nSelect a box or termination point (press Enter to end): "))) (setq ent-type (cdr (assoc 0 (entget ent)))) (if (= ent-type "INSERT") (setq boxes (cons ent boxes)) (setq terminations (cons ent terminations)) ) ) (setq cabinet-center (list (car center-point) (cadr center-point))) (foreach box boxes (setq box-xy (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))))) (setq polyline-start (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))) 0.0)) (draw-polyline polyline-start cabinet-center) ) (foreach termination terminations (setq termination-xy (list (car (cdr (assoc 10 (Apologies for the incomplete code in my previous response, here is the complete modified program to draw a polyline from every box or termination point to the cabinet, while respecting layer boundaries: ```lisp (defun c:ftth () (setq radius 0) (setq cabinet-capacity 0) ; Prompt the user for the radius and capacity (prompt "\nEnter the radius for the cabinet boundary (250 or 500): ") (setq radius (getreal)) (prompt "\nEnter the capacity of each cabinet: ") (setq cabinet-capacity (getint)) ; Define the function to create FTTH cabinets (defun create-cabinet (x y num) (setq quantity (* cabinet-capacity num)) (command "circle" x y radius) (command "text" (list (+ x radius) (+ y radius)) (strcat "Cabinet " (itoa num))) (list num quantity) ) ; Define the function to draw polyline (defun draw-polyline (start end) (setq old-layer (getvar "clayer")) (setq layer-name (cdr (assoc 8 (entget start)))) (setq color (cdr (assoc 62 (entget start)))) (setq polyline (entmakex (list '(0 . "LWPOLYLINE") '(8 . layer-name) '(62 . color) '(10 . (car (cdr (assoc 10 (entget start)))))))) (setq vertex-list (list (cdr (assoc 10 (entget start))) (cdr (assoc 10 (entget end)))))) (command "pedit" polyline "" "M" vertex-list "") (setvar "clayer" old-layer) ) ; Get user input for cabinet positions (setq p1 (getpoint "\nEnter the first cabinet position: ")) (setq p2 (getpoint "\nEnter the second cabinet position: ")) ; Calculate the center point of the cabinet boundary (setq center-point (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))) ; Calculate the distance from the center point to the cabinet positions (setq distance (distance center-point p1)) ; Create the cabinet boundary (command "circle" center-point distance) ; Create cabinets within the boundary (setq angle-step (/ (* 2 pi) cabinet-capacity)) (setq current-angle 0) (setq cabinet-data '()) (repeat cabinet-capacity (setq x (polar center-point current-angle distance)) (setq y (+ (cadr x) (cadr center-point))) (setq x (+ (car x) (car center-point))) (setq result (create-cabinet x y (+ 1 cabinet-data-length))) (setq cabinet-data (cons result cabinet-data)) (setq current-angle (+ current-angle angle-step)) ) ; Output the cabinet data (setq cabinet-data-length (length cabinet-data)) (setq table (tblnext "TABLE" 1)) (setq row (tbladd table)) (tblset row '("Cabinet Number" "Quantity")) (repeat cabinet-data-length (setq item (nth (- cabinet-data-length 1) cabinet-data)) (setq cabinet-number (nth 0 item)) (setq quantity (nth 1 item)) (setq row (tbladd table)) (tblset row (list (strcat "Cabinet " (itoa cabinet-number)) quantity)) (setq cabinet-data-length (- cabinet-data-length 1)) ) (tblout table) ; Draw polyline from every box or termination point to the cabinet (setq boxes '()) (setq terminations '()) (while (setq ent (car (entsel "\nSelect a box or termination point (press Enter to end): "))) (setq ent-type (cdr (assoc 0 (entget ent)))) (if (= ent-type "INSERT") (setq boxes (cons ent boxes)) (setq terminations (cons ent terminations)) ) ) (setq cabinet-center (list (car center-point) (cadr center-point))) (foreach box boxes (setq box-xy (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))))) (setq polyline-start (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))) 0.0)) (draw-polyline polyline-start cabinet-center) ) (foreach termination terminations (setq termination-xy (list (car (cdr (assoc ss.dwg City View -D Secondary Layout.dwg Edited June 26, 2023 by SLW210 Code Tags!! Quote
SLW210 Posted June 26, 2023 Posted June 26, 2023 You posted on the weekend, be patient. Please use code tags, <> in the menu bar in the reply box. Your code looks incomplete, is that all of it? 1 1 Quote
wkplan Posted June 26, 2023 Posted June 26, 2023 19 hours ago, Hassan95 said: Is anyone here can help me. I cam across this. Conversation. It's very helpful. Can I show you my ftth example so anyone can develop a lisp to save me i tried chat-gbt and it gave me (defun c:ftth () (setq radius 0) (setq cabinet-capacity 0) ; Prompt the user for the radius and capacity (prompt "\nEnter the radius for the cabinet boundary (250 or 500): ") (setq radius (getreal)) (prompt "\nEnter the capacity of each cabinet: ") (setq cabinet-capacity (getint)) ; Define the function to create FTTH cabinets (defun create-cabinet (x y num) (setq quantity (* cabinet-capacity num)) (command "circle" x y radius) (command "text" (list (+ x radius) (+ y radius)) (strcat "Cabinet " (itoa num))) (list num quantity) ) ; Define the function to draw polyline (defun draw-polyline (start end) (setq old-layer (getvar "clayer")) (setq layer-name (cdr (assoc 8 (entget start)))) (setq color (cdr (assoc 62 (entget start)))) (setq polyline (entmakex (list '(0 . "LWPOLYLINE") '(8 . layer-name) '(62 . color) '(10 . (car (cdr (assoc 10 (entget start)))))))) (setq vertex-list (list (cdr (assoc 10 (entget start))) (cdr (assoc 10 (entget end)))))) (command "pedit" polyline "" "M" vertex-list "") (setvar "clayer" old-layer) ) ; Get user input for cabinet positions (setq p1 (getpoint "\nEnter the first cabinet position: ")) (setq p2 (getpoint "\nEnter the second cabinet position: ")) ; Calculate the center point of the cabinet boundary (setq center-point (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))) ; Calculate the distance from the center point to the cabinet positions (setq distance (distance center-point p1)) ; Create the cabinet boundary (command "circle" center-point distance) ; Create cabinets within the boundary (setq angle-step (/ (* 2 pi) cabinet-capacity)) (setq current-angle 0) (setq cabinet-data '()) (repeat cabinet-capacity (setq x (polar center-point current-angle distance)) (setq y (+ (cadr x) (cadr center-point))) (setq x (+ (car x) (car center-point))) (setq result (create-cabinet x y (+ 1 cabinet-data-length))) (setq cabinet-data (cons result cabinet-data)) (setq current-angle (+ current-angle angle-step)) ) ; Output the cabinet data (setq cabinet-data-length (length cabinet-data)) (setq table (tblnext "TABLE" 1)) (setq row (tbladd table)) (tblset row '("Cabinet Number" "Quantity")) (repeat cabinet-data-length (setq item (nth (- cabinet-data-length 1) cabinet-data)) (setq cabinet-number (nth 0 item)) (setq quantity (nth 1 item)) (setq row (tbladd table)) (tblset row (list (strcat "Cabinet " (itoa cabinet-number)) quantity)) (setq cabinet-data-length (- cabinet-data-length 1)) ) (tblout table) ; Draw polyline from every box or termination point to the cabinet (setq boxes '()) (setq terminations '()) (while (setq ent (car (entsel "\nSelect a box or termination point (press Enter to end): "))) (setq ent-type (cdr (assoc 0 (entget ent)))) (if (= ent-type "INSERT") (setq boxes (cons ent boxes)) (setq terminations (cons ent terminations)) ) ) (setq cabinet-center (list (car center-point) (cadr center-point))) (foreach box boxes (setq box-xy (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))))) (setq polyline-start (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))) 0.0)) (draw-polyline polyline-start cabinet-center) ) (foreach termination terminations (setq termination-xy (list (car (cdr (assoc 10 (Apologies for the incomplete code in my previous response, here is the complete modified program to draw a polyline from every box or termination point to the cabinet, while respecting layer boundaries: ```lisp (defun c:ftth () (setq radius 0) (setq cabinet-capacity 0) ; Prompt the user for the radius and capacity (prompt "\nEnter the radius for the cabinet boundary (250 or 500): ") (setq radius (getreal)) (prompt "\nEnter the capacity of each cabinet: ") (setq cabinet-capacity (getint)) ; Define the function to create FTTH cabinets (defun create-cabinet (x y num) (setq quantity (* cabinet-capacity num)) (command "circle" x y radius) (command "text" (list (+ x radius) (+ y radius)) (strcat "Cabinet " (itoa num))) (list num quantity) ) ; Define the function to draw polyline (defun draw-polyline (start end) (setq old-layer (getvar "clayer")) (setq layer-name (cdr (assoc 8 (entget start)))) (setq color (cdr (assoc 62 (entget start)))) (setq polyline (entmakex (list '(0 . "LWPOLYLINE") '(8 . layer-name) '(62 . color) '(10 . (car (cdr (assoc 10 (entget start)))))))) (setq vertex-list (list (cdr (assoc 10 (entget start))) (cdr (assoc 10 (entget end)))))) (command "pedit" polyline "" "M" vertex-list "") (setvar "clayer" old-layer) ) ; Get user input for cabinet positions (setq p1 (getpoint "\nEnter the first cabinet position: ")) (setq p2 (getpoint "\nEnter the second cabinet position: ")) ; Calculate the center point of the cabinet boundary (setq center-point (polar p1 (angle p1 p2) (/ (distance p1 p2) 2))) ; Calculate the distance from the center point to the cabinet positions (setq distance (distance center-point p1)) ; Create the cabinet boundary (command "circle" center-point distance) ; Create cabinets within the boundary (setq angle-step (/ (* 2 pi) cabinet-capacity)) (setq current-angle 0) (setq cabinet-data '()) (repeat cabinet-capacity (setq x (polar center-point current-angle distance)) (setq y (+ (cadr x) (cadr center-point))) (setq x (+ (car x) (car center-point))) (setq result (create-cabinet x y (+ 1 cabinet-data-length))) (setq cabinet-data (cons result cabinet-data)) (setq current-angle (+ current-angle angle-step)) ) ; Output the cabinet data (setq cabinet-data-length (length cabinet-data)) (setq table (tblnext "TABLE" 1)) (setq row (tbladd table)) (tblset row '("Cabinet Number" "Quantity")) (repeat cabinet-data-length (setq item (nth (- cabinet-data-length 1) cabinet-data)) (setq cabinet-number (nth 0 item)) (setq quantity (nth 1 item)) (setq row (tbladd table)) (tblset row (list (strcat "Cabinet " (itoa cabinet-number)) quantity)) (setq cabinet-data-length (- cabinet-data-length 1)) ) (tblout table) ; Draw polyline from every box or termination point to the cabinet (setq boxes '()) (setq terminations '()) (while (setq ent (car (entsel "\nSelect a box or termination point (press Enter to end): "))) (setq ent-type (cdr (assoc 0 (entget ent)))) (if (= ent-type "INSERT") (setq boxes (cons ent boxes)) (setq terminations (cons ent terminations)) ) ) (setq cabinet-center (list (car center-point) (cadr center-point))) (foreach box boxes (setq box-xy (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))))) (setq polyline-start (list (car (cdr (assoc 10 (entget box)))) (cadr (cdr (assoc 10 (entget box)))) 0.0)) (draw-polyline polyline-start cabinet-center) ) (foreach termination terminations (setq termination-xy (list (car (cdr (assoc ss.dwg 1.02 MB · 0 downloads City View -D Secondary Layout.dwg 2.77 MB · 0 downloads @Hassan95 Maybee I'm off-topic, but: Did you seriously aked a AI? And then you want the forum to finish this job? I wonder how long it will take, AIs register this forum, begging for help yust my 2 cts Wolfgang 1 Quote
Steven P Posted June 26, 2023 Posted June 26, 2023 For Hassan, just to note that I love these types of questions "this isn't working, please help" - but of course, no description of what isn't working and any errors that your CAD throws up when you ty to run the LISP. Following what SW210 says your code looks to be inconplete, finishing with (foreach termination terminations (setq termination-xy (list (car (cdr (assoc I have never used ChatGPT, actually quite enjoy working out the puzzles that LISP throws up by myself, but I gather you ask it questions and set out the procedure you want the LISP to do, so my next question should be easy - what do you want the LISP to do exactly? Assuming again that you want it to speed up a process you do just now, what is this process? For example: 1. Set the cabinet radius 2. Set the cabinet positions 3. Loop to set the cabinet positions and so on (Noting here that ChatGPT uses its best guess of internet searches to produce a code but won't test what it says actually works as required( 1 Quote
Hassan95 Posted June 28, 2023 Posted June 28, 2023 On 6/26/2023 at 4:38 PM, Steven P said: For Hassan, just to note that I love these types of questions "this isn't working, please help" - but of course, no description of what isn't working and any errors that your CAD throws up when you ty to run the LISP. Following what SW210 says your code looks to be inconplete, finishing with (foreach termination terminations (setq termination-xy (list (car (cdr (assoc I have never used ChatGPT, actually quite enjoy working out the puzzles that LISP throws up by myself, but I gather you ask it questions and set out the procedure you want the LISP to do, so my next question should be easy - what do you want the LISP to do exactly? Assuming again that you want it to speed up a process you do just now, what is this process? For example: 1. Set the cabinet radius 2. Set the cabinet positions 3. Loop to set the cabinet positions and so on (Noting here that ChatGPT uses its best guess of internet searches to produce a code but won't test what it says actually works as required( I asked chat-gpt this. can you design AN AUTOCAD LISP THAT CAN DESIGN FTTH NETWORK AND MAKE A TABLE OF quantitIES USED IN PLANNIG . MAKE THAT LISP HAVE OPTION TO MAKE CABINET ZONES 1. BASED ON cabinet capacity 2. BASED ON MAKING boundary AROUND CABINETS CAN BE CONTAIND IN A circle with radius (LET ME CHOOSE 250 m OR 500 m ). CAN YOU MAKE IT DRAW A POLYLINE FROM EVRY BOX OR TERMINATION POINT TO THE CABINET RESPCTING LAYER BOUNDRIES. Quote
Hassan95 Posted June 28, 2023 Posted June 28, 2023 For me its very time consuming effort to connect every termination point to it's corresponding cabinet over polyline represents pipes or conduits or cable tray. I have searched a lisp that does it but I didn't found any. Quote
BIGAL Posted June 29, 2023 Posted June 29, 2023 Sometimes the mention of $$ will reveal a provider who can talk direct to you about your task. Quote
SLW210 Posted June 29, 2023 Posted June 29, 2023 Is this something AutoCAD Electrical or MEP can handle? What's wrong with the other LISP in this thread? You have yet to answer any of the questions already asked. Quote
JuniorNogueira Posted June 29, 2023 Posted June 29, 2023 @alex198617 If you are in Brazil you can check out my FTTx.CAD toolkit. download link: FTTx.CAD - Download and Installation Se estiver no Brasil você pode conhecer meu conjunto de ferramenta FTTx.CAD. link para dowload: FTTx.CAD - Download e Instalação 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.