See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Connect Block to rectangle lisp

  1. #1
    I could stop if I wanted to
    Join Date
    2009-10
    Posts
    262
    Login to Give a bone
    0

    Default Connect Block to rectangle lisp

    Code:
    (Defun:Rectest ()
      (if
        (and (SETQ PT1 (GETPOINT "\nPick lower left corner of window: "))
    	 (setq pt2 (getcorner pt1 "\nPick upper right corner of window: "))
        )
         (progn
           (command "_rectangle" "F" ".0625" "W" ".0625" pt1 pt2)
           (setvar 'osmode osmode)
         )
      )
     
      
      (SETQ PT3 (GETPOINT "Pick Detail Callout Location: "))
    
      (command "_.insert" "Detail Callout" PT3 "" "" "" Sheet# Detail# "")
    )

    Would anyone be able to help me do something in my code... i'm a little stumped in how to proceed...

    I'd like to have this code draw a line automatically, without further input, (two lines if necessecary) from the closest point on the circle (Detail Callout) to the rectangle that was just drawn
    though i would like the line to connect only in a perpendicular manner to the rectangle, (At least 1/4" away from the corners of the rectangle) like the pictures attached.

    Attached are the sample pictures, lisp, and block.
    Attached Images Attached Images
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2009-10
    Posts
    262
    Login to Give a bone
    0

    Default Re: Connect Block to rectangle lisp

    While I understand this may be a lot to ask if anyone has an application i can reference that does something similar it would be greatly appreciated

  3. #3
    I could stop if I wanted to
    Join Date
    2008-05
    Location
    Yardley, PA
    Posts
    305
    Login to Give a bone
    0

    Default Re: Connect Block to rectangle lisp

    It's been awhile for me, and if not sure if this would save any time than drafting it.... You could you have it stop and ask the user where to insert the callout, save that point or have it directly start drawing the line from that point and then stop for user input again and say say where do you want to terminate the line and then there you go...

    anyway. not sure if writing this would be any quicker than just drawing it....

  4. #4
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    1

    Default Re: Connect Block to rectangle lisp

    Quote Originally Posted by mbrandt5 View Post
    While I understand this may be a lot to ask if anyone has an application i can reference that does something similar it would be greatly appreciated
    Here is a very quick stab at it (modified your code).
    I used layers and a block I use, but kept your rectangle line width settings.
    (National Cad Standards layers and block)

    This only places a line to the bubble perpendicular to the right side of the rectangle, all at a scale of 1:1.
    It prompts you to fill in the attributes.

    Hope this helps you on your way.
    I may improve on this for my own needs an pe-post later.
    Code:
    (Defun:Rectest ()
    (setq cmde (getvar "cmdecho"))
    (setq osm (getvar "osmode"))
    (setvar "cmdecho" 1)
    (setvar "attreq" 1)
    (setvar "attdia" 1)
    (setq la (getvar "clayer"))
    	(SETQ LR1 (TBLSEARCH "LAYER" "G-ANNO-SYMB"))   
    	(SETQ LR2 (TBLSEARCH "LAYER" "G-ANNO-SYMB-DETL"))
    		(IF (= LR1 NIL)
    		(command "layer" "make" "G-ANNO-SYMB" "color" "3" "" "lw" "0.35" "" ""))
    		(IF (= LR2 NIL)
    		(command "layer" "make" "G-ANNO-SYMB-DETL" "COLOR" "14" "" "lw" "0.7" "" "LT" "HIDDEN2" "" ""))
    (command "layer" "t" "G-ANNO-SYMB-DETL" "S" "G-ANNO-SYMB-DETL" "")
    (setvar "osmode" 0)
      (if
        (and (setq pt1 (getpoint "\nPick lower left corner of window: "))
    	 (setq pt2 (getcorner pt1 "\nPick upper right corner of window: "))
        )
         (progn
           (command "_rectangle" "F" ".0625" "W" ".0625" pt1 pt2)
             )
      )
    (setq pt3 (getpoint "Pick Detail Callout Location: "))
    
    (setq px4 (car pt2))
    (setq py4 (cadr pt3))
    (setq pt4 (list px4 py4 0))
    	
    (command "layer" "t" "G-ANNO-SYMB" "S" "G-ANNO-SYMB" "")
    (command "_.insert" "NCS_DETL" pt3 "" "" "")
    (command "line" pt4 pt3 "")
    (setvar "osmode" osm)
    (setvar "clayer" la)
    (setvar "cmdecho" cmde)
    )
    Last edited by tedg; 2016-05-20 at 01:59 PM. Reason: clarified description

  5. #5
    I could stop if I wanted to
    Join Date
    2009-10
    Posts
    262
    Login to Give a bone
    0

    Default Re: Connect Block to rectangle lisp

    Thanks i greatly appreciate it...

    For the time being I just used the pline command
    as part of the code.

    If the block isn't inserted with the base point on the side nearest the rectangle it would overlap.

    Also if its not perpendicular to the rectangle it wouldn't connect.

  6. #6
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Connect Block to rectangle lisp

    Quote Originally Posted by mbrandt5 View Post
    Thanks i greatly appreciate it...

    For the time being I just used the pline command
    as part of the code.

    If the block isn't inserted with the base point on the side nearest the rectangle it would overlap.

    Also if its not perpendicular to the rectangle it wouldn't connect.
    You're welcome, glad I could help.
    You have a good idea, instead of trying to automatically connect the bubble to the rectangle with line/pline..
    It may be better (easier) to simply have code prompting to draw a pline from the rectangle to the bubble.

    I may do that for my own self

    [cheers]

  7. #7
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Default Re: Connect Block to rectangle lisp

    Inspired by the OP, here is my updated routine that works for my needs and at the company I work for.
    Similar to the code "mbrandt5" started with and what I posted earlier, but this also:
    • Asks what scale to be drawing at (1 = PS, 48 = 1/4" = 1'-0", 96 = 1/8" = 1'-0" etc.)
    • Rectangle has a plinewid of 0 (lineweight ByLayer) and radius of 1/4"
    • After placing the detail call out, draws a polyline (you pick 3-points)
    • Loads the callout "block" from a known address



    Code:
    ;; DETAIL RECTANGLE AND CALLOUT ROUTINE
    ;; 2016-05-20 TED G.
    ;; CREATES NCS LAYERS AND USES NCS DETAIL CALLOUT
    
    (defun C:detb ()
    (setq cmde (getvar "cmdecho"))
    (setq osm (getvar "osmode"))
    (setvar "cmdecho" 1)
    (setvar "attreq" 1)
    (setvar "attdia" 1)
    (setq scl (getdist "What Scale is this being drawn at? (paperspace = 1) Type a Number! "))(terpri)
    (setq rad1 (* 0.25 scl))
    (setq la (getvar "clayer"))
    	(SETQ LR1 (TBLSEARCH "LAYER" "G-ANNO-SYMB"))   
    	(SETQ LR2 (TBLSEARCH "LAYER" "G-ANNO-SYMB-DETL"))
    		(IF (= LR1 NIL)
    		(command "layer" "make" "G-ANNO-SYMB" "color" "3" "" "lw" "0.35" "" ""))
    		(IF (= LR2 NIL)
    		(command "layer" "make" "G-ANNO-SYMB-DETL" "COLOR" "14" "" "lw" "0.7" "" "LT" "DASHED2" "" ""))
    (command "layer" "t" "G-ANNO-SYMB-DETL" "S" "G-ANNO-SYMB-DETL" "")
    (setvar "osmode" 0)
      (if
        (and (setq pt1 (getpoint "\nPick lower left corner of window: "))
    	 (setq pt2 (getcorner pt1 "\nPick upper right corner of window: "))
        )
         (progn
           (command "_rectangle" "f" rad1 pt1 pt2)
             )
      )
    (setq pt3 (getpoint "Pick Detail Callout Location: "))
    	
    (command "layer" "t" "G-ANNO-SYMB" "S" "G-ANNO-SYMB" "")
    (command "-insert" "c:\\lisp\\NCS_DETL""scale" scl pt3 "")
    (setvar "osmode" 643)
    (command "_pline" pause pause pause "")
    (setvar "osmode" osm)
    (setvar "clayer" la)
    (setvar "cmdecho" cmde)
    (princ)
    )
    (princ "\nDETB.lsp loaded, command: DETB, see command line for prompts")

Similar Threads

  1. Lisp for rectangle
    By RRS1987 in forum AutoLISP
    Replies: 2
    Last Post: 2011-10-24, 02:58 AM
  2. Replies: 3
    Last Post: 2009-04-15, 07:30 PM
  3. Can pipes connect to the Face of a rectangle box?
    By Spell in forum AutoCAD Civil 3D - Pipes
    Replies: 10
    Last Post: 2009-01-21, 06:30 PM
  4. create an excel of block attributes from within a specified rectangle
    By christopher.r.schroll in forum VBA/COM Interop
    Replies: 1
    Last Post: 2008-05-20, 02:33 PM
  5. LISP to calculate area of rectangle
    By Rynakor in forum AutoLISP
    Replies: 13
    Last Post: 2006-06-20, 01:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •