Leaderboard
Popular Content
Showing content with the highest reputation on 04/25/2022 in all areas
-
; Cable Tray Cable Section - 2022.04.25 exceed ; this is Simple lisp for 'draw the section of tray & cables' ; tray width is user input ; tray height is 150 fixed, lung space 20 is also fixed. (vl-load-com) (defun c:CTCS ( / *error* traywidth trayheight traylung basept baseptx numberyn cablestartptx cablestartpty widthlimit heightlimit returnx maxodin1layer cablemm2 cablemm2sum index cableqty cableod cablecenterpt traymm2 index2 ) (setvar 'cmdecho 0) (LM:startundo (LM:acdoc)) ;error control (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\n Error: " msg)) ) (princ "\n Cable Space = ") (princ cablemm2sum) (princ " mm^2 / ") (princ "Tray Space = ") (princ traymm2) (princ " mm^2 = ") (princ (rtos (* (/ cablemm2sum traymm2) 100) 2 2)) (princ " %") (setvar 'cmdecho 1) (princ) ) (setq traywidth (getreal "\n Input Tray Width (150/300/600/900) = ")) (setq trayheight 150) (setq traylung 20) (setq traymm2 0) (setq traymm2 (* (- trayheight traylung) traywidth)) (setq basept (getpoint "\n pick point for tray = ")) (setq baseptx (car basept)) (setq basepty (cadr basept)) (princ (list baseptx basepty)) (entmake (list '(0 . "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 67 0) (cons 8 "0") (cons 100 "AcDbPolyline") (cons 90 4) (cons 70 1) (cons 43 0) (cons 38 0) (cons 39 0) (cons 10 (list (+ baseptx 25) (+ basepty 5))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 25) (+ basepty traylung))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 25) (+ basepty 0))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 0) (+ basepty 0))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 0) (+ basepty 5))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 20) (+ basepty 5))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 20) (+ basepty 145))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 0) (+ basepty 145))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 0) (+ basepty 150))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 25) (+ basepty 150))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx 25) (+ basepty traylung))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 25)) (+ basepty traylung))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 25)) (+ basepty 150))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 50)) (+ basepty 150))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 50)) (+ basepty 145))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 30)) (+ basepty 145))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 30)) (+ basepty 5))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 50)) (+ basepty 5))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 50)) (+ basepty 0))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 25)) (+ basepty 0))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 25)) (+ basepty traylung))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) (cons 10 (list (+ baseptx (+ traywidth 25)) (+ basepty 5))) (cons 40 0) (cons 41 0) (cons 42 0) (cons 91 0) ) ); end of entmake (setq numberyn (getstring "\n Place Number to Cables? (Y/N)")) (setq cablestartptx (+ baseptx 25)) (setq cablestartpty (+ basepty traylung)) (setq widthlimit (+ cablestartptx traywidth)) (setq heightlimit (+ cablestartpty (- trayheight traylung))) (setq returnx cablestartptx) (setq maxodin1layer 0) (setq cablemm2 0) (setq cablemm2sum 0) (setq index 0) ;repeat index for numbering (setq index2 0) ;while index for coloring (while (setq cableod (getreal "\n Input Cable O.D. = ")) (setq cableqty (getint "\n Input Cable Q'ty = ")) (setq cablemm2 (* cableod cableod)) (repeat cableqty (if (> cableod maxodin1layer) (setq maxodin1layer cableod) ) (if (> (+ cablestartpty cableod) heightlimit) (princ "\n It's overload") ) (setq cablecenterpt (list (+ cablestartptx (/ cableod 2)) (+ cablestartpty (/ cableod 2)) 0 )) (entmake (list '(0 . "CIRCLE") (cons 8 "0") (cons 10 cablecenterpt) (cons 40 (/ cableod 2)) (cons 62 (+ index2 1)) )) (if (= (strcase numberyn) "Y") (entmake (list '(0 . "TEXT") (cons 100 "AcDbEntity") (cons 67 0) (cons 8 "0") (cons 100 "AcDbText") (cons 10 cablecenterpt) (cons 40 (/ cableod 2)) (cons 1 (vl-princ-to-string (+ index 1))) (cons 50 0) (cons 41 1) (cons 51 0) (cons 7 "Standard") (cons 71 0) (cons 72 1) (cons 11 cablecenterpt) (cons 100 "AcDbText") (cons 73 2) (cons 62 (+ index2 1)) )) ) (setq cablestartptx (+ cablestartptx cableod)) (setq cablemm2sum (+ cablemm2sum cablemm2)) (if (> (+ cablestartptx cableod) widthlimit) (progn (setq cablestartpty (+ cablestartpty maxodin1layer)) (setq cablestartptx returnx) (setq maxodin1layer 0) ) ) (setq index (+ index 1)) );end of repeat (setq index2 (+ index2 1)) );end of while (*error*) (princ) );end of defun ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) this time, I practiced 'while'. draw a cross section of the 1ea ladder cable tray, and fill the cables with od and quantity. - the cable area was calculated as a rectangle rather than a circle for unusable space. - the highest od on one floor becomes the bottom of the next floor. to improve this i think 1. I have to study the 'Bin Packing Problem' It is expected to be quite quite difficult. - If there is an example of solving BPP with lisp, please let me know. That's also why I wrote this. 2. it can be developed by taking the cable name and od from Excel and making it into a table 3. visualize the floor area ratio calculation using a hatch I didn't do the 2 and 3, because I didn't need them for my work this time.2 points
-
There is p3 in the picture saying you only need 2 points. this confused me. haha "If user select 2 point (i.e point1 and point2) then angle has to come 90 degree = this is xz plane And angle between point p2 and point 3 has to come 0 degree = this is rotated xz plane. And angle between point p3 and point p2 180 degree" = this is rotated xz plane. > this is second confused point. if p2 -> p1 in 2nd and 3rd line. there 3 lines explain just 1 xz plane. "Angle function is used to find angle between point which lies in xy plane but what about the point which is lies in xz and yz plane And how to measure the angle between them" > If this is what you meant to say, there is a simple way. ; get angle anyway - 2022.04.25 exceed ; measures the angle between 2 points projected on the xy yz xz planes. (defun c:getangleanyway ( / p1 p2 p1x p1y p1z p2x p2y p2z xyang yzang xzang) (princ "\n measures the angle between 2 points projected on the xy yz xz planes.") (setq p1 (getpoint "\n pick 1st point :")) (setq p2 (getpoint "\n pick 2nd point :")) (setq p1x (car p1)) (setq p1y (cadr p1)) (setq p1z (caddr p1)) (setq p2x (car p2)) (setq p2y (cadr p2)) (setq p2z (caddr p2)) (setq xyang (angle (list p1x p1y) (list p2x p2y))) (setq yzang (angle (list p1y p1z) (list p2y p2z))) (setq xzang (angle (list p1x p1z) (list p2x p2z))) (princ "\n xy angle = ") (princ xyang) (princ " (= ") (princ (/ (* xyang 180.0) pi)) (princ " degree)") (princ "\n yz angle = ") (princ yzang) (princ " (= ") (princ (/ (* yzang 180.0) pi)) (princ " degree)") (princ "\n xz angle = ") (princ xzang) (princ " (= ") (princ (/ (* xzang 180.0) pi)) (princ " degree)") (princ) ) in others way, If you want to measure an angle from two 3d points, you can make a plane from it by specifying the 3rd point make 2 vectors from the 3rd common point, and then get the angle between them. because an angle must have three points. but I think you mean something simpler. so this Lisp separates the x, y, z values of 2 points and when measuring the xy angle, only input the x and y values to "angle" and when measuring the yz angle, only input the y and z values to "angle" and when measuring the xz value, only input the x and z values to "angle" If "angle" only works for x and y, so put the y and z values there x and y position. this is a projection.2 points
-
Nice, never thought about drawing cable tray with a LISP like that, I have LISPs to draw common blocks, quicker to insert using keywords rather than pop ups, I might borrow what you have done. For power cables we often install them in trefoil arrangement - something in the back of my mind to create one day though it is just 3 circles, and we will often have a spacing between groups of power cables, not sure if that is also something to consider here?1 point
-
Its a fas so useless for us to look at as its compiled. So you picking points in some way so AGAIN why not do the label when you pick a point, it can be either on a pline or a offset point and the square off will be used. Do you really need the Excel ? This is real rough but gives you an idea of how it could be done. Need info like text style and height, correct version writes at 90 to pline. ; sq pt off pline (defun c:wow (obj pt pt2 dist ) (setq obj (vlax-ename->vla-object (car (entsel "Pick obj")))) (setvar 'textstyle "Standard") (while (setq pt (getpoint "\nPick point or Enter to exit ")) (setq pt2 (vlax-curve-getclosestpointto obj pt)) (setq dist (vlax-curve-getdistatpoint obj pt2)) (command "text" pt2 2.5 "" (rtos dist 2 3)) ) (princ) )1 point
-
Create an Attribute inside your dynamic block and use Field in the attribute value1 point