Author Topic: Electrical circuit lines  (Read 8142 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Electrical circuit lines
« on: March 13, 2004, 08:08:23 AM »
Does anyone have a copy of an lisp which will draw circuit lines from block to block by clicking on the blocks I wish to circuit one at a time?
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

DEVITG

  • Bull Frog
  • Posts: 480
block to block lines
« Reply #1 on: March 13, 2004, 03:33:44 PM »
A simple way is to pick the INSERTs of the blocks as the point and draw a line with those values .

Of course it will draw a straigt continuos line.
To draw ortho lines will need more effort.
 
Could you show your's blocks, puting it at the Lilly Pond?
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

hudster

  • Gator
  • Posts: 2848
Electrical circuit lines
« Reply #2 on: March 14, 2004, 09:34:43 AM »
HERE is a copy of a switched socket outlet block.

The line from the insertion point wouldn't work as the insertion point id 25mm below the bottom of the socket outlet.

at the moment Ii draw an arc between each outlet, but what I'd prefer to do is a 45 degree line from the centre of the socket, (trimmed to the edge of the circle) to the same level height as the endpoint of the switch line, before going to the next socket.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

DEVITG

  • Bull Frog
  • Posts: 480
Electrical circuit lines
« Reply #3 on: March 14, 2004, 10:56:47 AM »
Please put a sample of what do you do by hand.

 :D
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

DEVITG

  • Bull Frog
  • Posts: 480
Electrical circuit lines
« Reply #4 on: March 14, 2004, 12:19:49 PM »
Please check the insert point of the block

It is mid point of radious , 1.25 from the diameter line.

Do you draw scaled ?
Location @ Córdoba Argentina Using ACAD 2019  at Window 10

hyposmurf

  • Guest
Electrical circuit lines
« Reply #5 on: March 14, 2004, 12:23:00 PM »
If I'm drawing circuit lines for socket out lets I can either set my snap angle to 45 and then use a particular length for all the lines emerging from my socket outlet,then join them to the straight length of circuit (in your case an arc).The other way would to make blocks for each angle variation say 45°, 135° etc for the circuit line connecting the socket to the main run of circuit line.I'd like a better solution myself but havent come across one yet. :(

hudster

  • Gator
  • Posts: 2848
Electrical circuit lines
« Reply #6 on: March 14, 2004, 01:07:12 PM »
This is what I mean.



oops, forgot the drawing I measured the insertion point was scaled.

We insert below the block, so there is a gap when we click on the wall for insertion, looks better when we plot.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

SMadsen

  • Guest
Electrical circuit lines
« Reply #7 on: March 15, 2004, 03:09:34 PM »
Hudster, try this. Not exactly what you're after because its use is limited - but it was fun to do. It's based on the block P002 that you posted (although it'll take any block with an arc). Rotated blocks are not supported!

Call with command BLINE, pick a starting block, go to next block until a cyan box appears and click it to land on it (or go to next block). When selected, adjust height of circuit line by dragging.
It doesn't support osnaps or keyboard input (which is why it's of limited use).

Code: [Select]
(defun drawbox (pt aspect color / aspect n pt)
     (grvecs (cons color
                   (mapcar '(lambda (n) (polar pt (* pi n) aspect))
                           '(0.25 0.75 0.75 1.25 1.25 1.75 1.75 0.25)))
     )
)

(defun drawLeader (spt ang hpt ept nang draw / ipt cpt rlst)
  (cond ((setq apt (inters spt (polar spt ang 100.0)
                           hpt (setq ipt (list 100.0 (cadr hpt)))
                           nil)
         )
         (and ept (setq ipt (inters hpt ipt ept (polar ept nang 100.0) nil))
              (setq cpt (inters spt apt npt ipt nil)))
                (if cpt
                  (cond ((>= (cadr apt) (cadr cpt))
                         (if draw (grvecs (list 5 spt cpt 5 cpt ept)))
                         (setq rlst (list spt cpt ept))
                        )
                        (T (if draw (grvecs (list 5 spt apt 5 apt ipt 5 ipt npt))))
                  )
                  (if draw (grvecs (list 5 spt apt 5 apt hpt)))
                )
        )
  )
  (if rlst rlst (list spt apt ipt ept))
)

(defun getEnt (lst msg / ent)
  (setvar "ERRNO" 0)
  (or msg (setq msg "Select object: "))
  (while (and (not ent) (/= (getvar "ERRNO") 52))
    (cond ((setq ent (car (entsel msg)))
           (if (not (member (cdr (assoc 0 (entget ent))) lst))
             (setq ent nil))
          )
    )
  )
  ent
)

(defun centerPt (insert / cenPt ent entl insLst insPt rad radPt)
  (and (setq insLst (entget insert))
       (setq insPt  (cdr (assoc 10 insLst))
             insRot (cdr (assoc 50 insLst))
             ent    (cdr (assoc -2 (tblsearch "BLOCK" (cdr (assoc 2 insLst)))))
       )
       (while (and ent
                   (/= (cdr (assoc 0 (setq entl (entget ent)))) "ARC"))
         (setq ent (entnext ent))
       )
       (and ent
            (setq cenPt (cdr (assoc 10 entl)))
            (= (setq scale (cdr (assoc 41 insLst)))
               (cdr (assoc 42 insLst))
               (cdr (assoc 43 insLst))
            )
            (setq radPt (mapcar '+
                                insPt
                                (mapcar '* cenPt (list scale scale scale)))
            )
            (setq rad (* (cdr (assoc 40 entl)) scale))
       )
  )
  (list radPt rad insRot)
)

(defun C:BLINE (/ ang    aspect eInfo  oInfo  ent    grPt   nEnt
                  nPt    oAng   pAng   pt     rad    radPt  rot
                  tmp)
  (cond
    ((and (setq ent (getEnt '("INSERT") nil))
          (apply 'and (setq eInfo (centerPt ent)))
     )
     (mapcar 'set '(radPt rad rot) eInfo)
     (setq aspect
            (* 5 (/ (getvar "VIEWSIZE") (cadr (getvar "SCREENSIZE")))))
     (prompt "\nSelect landing: ")
     (while (= 5 (car (setq grPt (grread T))))
       (redraw)
       (setq ang (+ (angle radPt (cadr grPt)) rot))
       (cond ((or (> ang (* 1.5 pi)) (< 0.0 ang (/ pi 2.0)))
              (setq pt   (polar radPt (setq pAng (/ pi 4.0)) rad)
                    oAng (+ pAng (/ pi 2.0))
              )
             )
             (T (setq pt   (polar radPt (setq pAng (* pi 0.75)) rad)
                      oAng (- pAng (/ pi 2.0))))
       )
       (drawbox pt aspect 3)
       (cond
         ((and (setq tmp (nentselp (cadr grPt)))
               (> (length tmp) 2)
               (not (equal (setq nEnt (last (last tmp))) ent))
               (apply 'and (setq oInfo (centerPt nent)))
               (setq nPt (polar (car oInfo) oAng (cadr oInfo)))
          )
          (drawBox nPt aspect 4)
         )
         (T (setq nPt nil tmp nil))
       )
     ) ;_ while
     (cond
       ((and (= (car grPt) 3) tmp)
        (while (= 5 (car (setq grPt (grread T))))
          (redraw)
          (drawLeader pt pAng (cadr grPt) nPt oAng T))
        (cond
          ((and (= (car grPt) 3)
             (apply 'and
               (setq tmp (drawLeader pt pang (cadr grPt) nPt oAng nil))))
           (while tmp
             (if (cadr tmp)
               (entmake (append (list
                                  '(0 . "LINE")
                                  '(100 . "AcDbEntity")
                                  '(100 . "AcDbLine")
                                )
                                (list (cons 10 (car tmp))
                                      (cons 11 (cadr tmp))))
               )
             )
             (setq tmp (cdr tmp)))
          )
        )
       )
     )
     (redraw)
    )
  )
  (princ)
)

hudster

  • Gator
  • Posts: 2848
Electrical circuit lines
« Reply #8 on: March 22, 2004, 03:08:59 PM »
I found this whilst trawling through the internet.

this was the lisp I was looking for.

Code: [Select]
;Degrees to Radians Function
(defun dtr (a)
   (* pi (/ a 180.0))
);defun
;Main Routine
(defun c:circ ( / olderr myerror #sn1 #sn2 )
   ; Error Function
   (defun myerror (s)
      (if (/= st "Function cancelled")
         (alert (strcat s "\nByee.... : " ))
      );if
      (setvar "aperture" #ap )
      (setvar "osmode" #os )
      (setvar "blipmode" #bm )
      (setvar "cmdecho" #ce )
      (setvar "expert" #ex )
      (setq *error* olderr)
      (princ)
   );defun
   (initget "Fifty Hundred" )
   (setq #d (getkword "\nScale> Fifty / <Hundred>: "))
   (setq #dist 565 )  
   (cond
      ((= #d "Fifty")
         (setq #dist 282.5 )
      )
   );cond
   (initget "Centre Edge" )
   (setq #p (getkword "\nCircuit From.. Edge / <Centre>: "))
   (setq #sn1 584 )
   (setq #sn1b "nod,ins,nea" )
   (setq #sn2 68 )
   (setq #sn2b "ins,cen" )
   (cond
      ((= #p "Edge")    
         (setq #sn1 18 )
         (setq #sn1b "mid,qua" )
         (setq #sn2 18 )
         (setq #sn2b "mid,qua" )
      )
   );cond
   (setq olderr *error*)
   (setq *error* myerror)
   (setq #ex (getvar "expert" ))
   (setvar "expert" 5 )
   (setq #ce (getvar "cmdecho" ))
   (setvar "cmdecho" 0)
   (setq #bm (getvar "blipmode" ))
   (setvar "blipmode" 0)
   (setq #ap (getvar "aperture" ))
   (setvar "aperture" 12)
   (setq #os (getvar "osmode" ))
   (setvar "osmode" 0 )
   (setq #dist2 0 )
   (setq #dist3 0 )
   (setq #flag1 1)
   (while #flag1
      (setvar "osmode" #sn1 )
      (setq #pik1 (getpoint "\nPick Point on Edge of 1st Symbol "))
      (if (= #pik1 nil ) (setq #flag1 nil)
         (progn
            (setq #pt1 #pik1 )    
            (setq #pt2 (osnap #pik1 #sn2b ))
            (setq #dist2 (distance #pt1 #pt2 ))
            (setq #pik2 (getpoint "\nPick Point on Edge of 2nd Symbol "))
            (setq #pt3 (osnap #pik2 #sn1b ))    
            (setq #pt4 (osnap #pik2 #sn2b ))
            (setq #dist3 (distance #pt4 #pt3 ))
            (setq #ang (angle #pt2 #pt4 ))
            (setvar "osmode" 0 )
            (setq #pt5 (polar #pt2 (+ #ang (dtr 45)) #dist2 ))
            (setq #pt6 (polar #pt2 (+ #ang (dtr 45)) #dist ))
            (setq #pt8 (polar #pt4 (+ #ang (dtr 135)) #dist3 ))
            (setq #pt7 (polar #pt4 (+ #ang (dtr 135)) #dist ))
            (command "line" #pt5 #pt6 #pt7 #pt8 "" )
         );progn
      );if
   );while
   (setvar "aperture" #ap )
   (setvar "osmode" #os )
   (setvar "blipmode" #bm )
   (setvar "cmdecho" #ce )
   (setvar "expert" #ex )
   (setq *error* olderr)
   (princ)
);defun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Circuiting Routine - 1 line
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun dtr (a)
   (* pi (/ a 180.0))
);defun
(defun c:circ1 ( / olderr myerror )
   (defun myerror (s)
      (if (/= st "Function cancelled")
         (alert (strcat s "\nByee.... : " ))
      );if
      (setvar "aperture" #ap )
      (setvar "cmdecho" #ce )
      (setvar "osmode" #os )
      (setq *error* olderr)
      (princ)
   );defun
   (setq olderr *error*)
   (setq *error* myerror)
   (setq #ce (getvar "cmdecho" ))
   (setvar "cmdecho" 0 )
   (setq #ap (getvar "aperture" ))
   (setvar "aperture" 12 )
   (setq #os (getvar "osmode" ))
   (setvar "osmode" 0 )
   (setq #dist 565 )
   (setq #dist2 0 )
   (setq #flag1 1)
   (while #flag1
      (setvar "osmode" 8 )
      (setq #pik1 (getpoint "\nPick Node on Edge of Symbol" ))  
      (if (= #pik1 nil) (setq #flag1 nil)
         (progn
            (setq #pt2 #pik1 )
            (setq #pt1 (osnap #pik1 "ins" ))
            (setq #dist2 (distance #pt1 #pt2 ))
            (setq #ang (angle #pt1 #pt2 ))
            (setq #pt3 (polar #pt1 #ang #dist2 ))
            (setq #pt4 (polar #pt1 #ang #dist ))
            (command "line" #pt3 #pt4 "" )
         );progn
      );if
   );while
   (setvar "aperture" #ap )
   (setvar "osmode" #os )
   (setvar "cmdecho" #ce )
   (setq *error* olderr)
   (princ)
);defun
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

hyposmurf

  • Guest
Electrical circuit lines
« Reply #9 on: March 29, 2004, 07:03:55 AM »
Just dug this little lisp up,still havent used it myself.

;******************************************
; CIRCUIT.LSP - ICON Computer Services
; This programs draws circuit lines
; easily between two points by picking and
; circuit line arrows
;******************************************
; Global variable - cirtdist for circuit distance

(princ "..")
(defun c:lcirt ()
(setvar "cmdecho" 0)
(command "undo" "mark")
(cirt)
(setvar "cmdecho" 1)
)


(defun cirt (/ pt1 pt2 ang dist w ang1 ang2 pt3 pt4)
(setq pt1 (getpoint "\nSelect First Circuit Point: "))
(setq pt2 (getpoint "\nSelect Second Circuit Point: " pt1))
(setq ang (angle pt1 pt2))
(if (= cirtdist nil)(setq cirtdist 1))
(setq dist cirtdist)
(setq w (rtos dist 2 1))
(setq dist (getdist (strcat
"\nSelect Distance For Circuit Line: <" w ">: ")pt1))
(if (/= dist nil) (setq cirtdist dist))
(setq ang1 (+ ang 0.785398))
(setq pt3 (polar pt1 ang1 cirtdist))
(setq ang2 (+ ang1 1.570796))
(setq pt4 (polar pt2 ang2 cirtdist))
(command ".pline" pt1 "w" 0 "" pt3 pt4 pt2 "")
(while (/= pt2 nil)
(setq pt1 pt2)
(setq pt2 (getpoint "\nSelect Next Circuit Point: " pt1))
   (if (/= pt2 nil)
      (progn
         (setq ang (angle pt1 pt2))
         (setq ang1 (+ ang 0.785398))
         (setq pt3 (polar pt1 ang1 cirtdist))
         (setq ang2 (+ ang1 1.570796))
         (setq pt4 (polar pt2 ang2 cirtdist))
         (command ".pline" pt1 pt3 pt4 pt2 "")
      );end progn
   );end if
);end while
(princ)
)




;**********************************************
; This is the circuit line arrow command
;**********************************************

(defun c:ldw ()
(setvar "cmdecho" 0)
(command "undo" "mark")
(command "layer" "m" "e631zx-circuit" "")
(if(not c:dw)(load"/acad/cadx/cadx2"))
(c:dw)
(setvar "cmdecho" 1)
(princ)
)