Author Topic: Polar lisp help needed...  (Read 3732 times)

0 Members and 1 Guest are viewing this topic.

hudster

  • Gator
  • Posts: 2848
Polar lisp help needed...
« on: August 31, 2004, 11:37:28 AM »
I have a lisp which draws circuits from block to block, and it's great, but it when two blocks are on walls at 90 degrees to each other it just draws the circuit straight to each block.

What I want it to do is draw the circuit line parallel to the wall to the apparent instersection of each block and then go to the next one.

It's kind of hard to describe so I've put up two images to show you what I mean.

   

Can someone give me few pointers on how to go about doing this.

Cheers
Andy
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

hudster

  • Gator
  • Posts: 2848
Polar lisp help needed...
« Reply #1 on: August 31, 2004, 11:44:00 AM »
Oops, Forgot to include the code.

Code: [Select]
;Degrees to Radians Function
(defun dtr (a)
   (* pi (/ a 180.0))
);defun
;Main Routine
(defun c:circuit ( / olderr myerror #sn1 #sn2 )
   ; Error Function
   (defun myerror (s)
      (if (/= st "Function cancelled")
         (prompt (strcat s "\nerror exiting now.... : " ))
      );if
      (setvar "aperture" #ap )
      (setvar "osmode" #os )
      (setvar "blipmode" #bm )
      (setvar "cmdecho" #ce )
      (setvar "expert" #ex )
      (setq *error* olderr)
      (princ)
   );defun
(if (not #d)
  (progn
   (initget (+ 1 2 4))
     (setq #d (getint "\nDrawing Scale: "))
   (setq #dist (* #d 5.75 ))
)
  ;else
 (setq #dist (* #D 5.75))
)
   (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 "pline" #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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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 "pline" #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

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Polar lisp help needed...
« Reply #2 on: August 31, 2004, 03:28:16 PM »
Perhaps I'm missing something but I can't get the routine to work at all.
TheSwamp.org  (serving the CAD community since 2003)

hyposmurf

  • Guest
Polar lisp help needed...
« Reply #3 on: August 31, 2004, 04:21:53 PM »
The defun is circuit,you enter the scale say 1:50 is 50 ,1:100 is 100.But the reason your having problems is you may need the single socket outlet block.Seems to work for me as I have a similar block but attaches the circuit to the block in the wrong places

hudster

  • Gator
  • Posts: 2848
Polar lisp help needed...
« Reply #4 on: August 31, 2004, 04:43:55 PM »
Sorry, you must enter the scale and then select edge or center.
Edge is for sockets and center is for other equipment.

But I never tend to use center, ever.  I'm planning to remove it when I finally re-write this lisp.
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

hyposmurf

  • Guest
Polar lisp help needed...
« Reply #5 on: August 31, 2004, 04:47:51 PM »
Thanks,I used to draw a line of a certain length then use my polar tracking,set at a specific angle.No more :dood: