+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Dec 2005
    Location
    Brandon, Manitoba, Canada
    Posts
    166

    Default calling another lisp from within my lisp

    Registered forum members do not see this ad.

    is it possible to call another lisp routine from within my lisp routine

    my code
    Code:
    ;Trim the leader line for bubbles
    
    (defun c:bt (/ what where scale blockname tryagain insertpoint)
      (princ "") 
      (command)
      ;allow three attampts to select the correct block
      (setq tryagain 3)
      &#40;while &#40;< 0 tryagain&#41;
        &#40;setq what nil&#41;
        &#40;print "Select Item Number Bubble..."&#41;
        &#40;setq what &#40;ssget "&#58;s"&#41;&#41;
        ;get name of the block
        &#40;setq blockname "no"&#41;
        &#40;setq blockname &#40;cdr&#40;assoc 2 &#40;entget&#40;ssname what 0&#41;&#41;&#41;&#41;&#41;
        ;get scale of the block
        &#40;setq scale &#40;cdr&#40;assoc 41 &#40;entget&#40;ssname what 0&#41;&#41;&#41;&#41;&#41;
        ;get the insertion point of the block
        &#40;setq insertpoint &#40;cdr&#40;assoc 10 &#40;entget&#40;ssname what 0&#41;&#41;&#41;&#41;&#41;
        ;check to make sure we have the right block "TABL213A"
          &#40;if &#40;= blockname "TABL213A"&#41;
    	  &#40;progn
    	    &#40;princ "That was a Item Number Bubble...working..."&#41;
                &#40;setq tryagain 0&#41;
    	    &#40;command "circle" insertpoint &#40;* 0.125 scale&#41;&#41;
    	    &#40;command "extrim" "l" insertpoint&#41;
    	    &#40;command "erase" "l" ""&#41;
              &#41;
              &#40;progn
    	    &#40;princ "That was not a Item Number Bubble... "&#41;&#40;princ tryagain&#41;&#40;princ " more tries..."&#41;
    	    &#40;setq tryagain &#40;1- tryagain&#41;&#41;
    	  &#41;
          &#41;
      &#41;
      ;&#40;redraw &#40;ssname what 0&#41; 3&#41;
      ;&#40;setq where &#40;getpoint "Select point..."&#41;&#41;
      ;&#40;command "break" what where "@0,0"&#41;
      ;&#40;princ "all done"&#41;
      ;&#40;princ&#41;
    &#41;
    extrim is part of the express tools. it is already loaded, as I can type in extrim on the command line and excute the extrim.lsp.

    Any insight is greatly appriciated.
    Thalon

  2. #2
    Super Member David Bethel's Avatar
    Discipline
    Multi-disciplinary
    David Bethel's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Commercial Food Service
    Using
    AutoCAD pre 2000
    Join Date
    Dec 2003
    Location
    Newport News, Virginia
    Posts
    1,926

    Default

    If extrim in a lisp commend and not ARX or VBA or whatever flavor of the day is popular, and the lisp command is global ( which I belive it is ) just use

    Code:
    &#40;c&#58;extrim&#41;
    The problem can come up with trying to send the variables along. Extrim probably has some (get_) function calls that cannot be bypassed. -David
    R12 (Dos) - A2K

  3. #3
    Senior Member
    Using
    AutoCAD 2005
    Join Date
    Dec 2005
    Location
    Brandon, Manitoba, Canada
    Posts
    166

    Default

    Registered forum members do not see this ad.

    thanks David.

    I modified my thought process a little and changed it to make my LISP work

    It trims the leader line for item number bubbles.

    Input ->
    - select you item number bubble block (you will need to modify the LISP file to suit you block name)
    What it does ->
    - draws a circle at the insertion point of the block. Circle size is based upon the scale of the block selected. (you may need to modify the circle command line to suit your radius of your bubbles)
    - calls the trim command to trim the line that must have an endpoint at the center of the bubble circle.
    - erases the circle

    This is a quick way to trim those lines to make to item number bubble look nice.

    Hope you find it useful.

    Code:
    ;Trim the leader line for bubbles
    ;Kevin Petursson February 22, 2006
    
    &#40;defun c&#58;bt &#40;/ what where scale blockname tryagain insertpoint whatlength&#41;
      ;allow three attampts to select the correct block
      &#40;setq tryagain 3&#41;
      &#40;while &#40;< 0 tryagain&#41;
        &#40;setq what nil&#41;
        &#40;print "Select Item Number Bubble..."&#41;
        ;&#40;setq what &#40;ssget "&#58;s"&#41;&#41;
        &#40;setq what &#40;ssget&#41;&#41;
        ;get name of the block
        &#40;setq whatlength &#40;sslength what&#41;&#41;
        &#40;setq whatlength &#40;1- whatlength&#41;&#41;
        &#40;while &#40;<= 0 whatlength&#41;
          &#40;setq blockname "no"&#41;
          &#40;setq blockname &#40;cdr&#40;assoc 2 &#40;entget&#40;ssname what whatlength&#41;&#41;&#41;&#41;&#41;
          ;get scale of the block
          &#40;setq scale &#40;cdr&#40;assoc 41 &#40;entget&#40;ssname what whatlength&#41;&#41;&#41;&#41;&#41;
          ;get the insertion point of the block
          &#40;setq insertpoint &#40;cdr&#40;assoc 10 &#40;entget&#40;ssname what whatlength&#41;&#41;&#41;&#41;&#41;
          ;check to make sure we have the right block "TABL213A"
            &#40;if &#40;= blockname "TABL213A"&#41;
      	  &#40;progn
    	    &#40;princ "That was a Item Number Bubble...working..."&#41;
                &#40;setq tryagain 0&#41;
    	    &#40;command "circle" insertpoint &#40;* 0.125 scale&#41;&#41;
    	    &#40;command "trim" "l" "" insertpoint ""&#41;
    	    &#40;command "erase" "l" ""&#41;
              &#41;
              &#40;progn
    	    &#40;princ "That was not a Item Number Bubble... "&#41;&#40;princ tryagain&#41;&#40;princ " more tries..."&#41;
    	    &#40;setq tryagain &#40;1- tryagain&#41;&#41;
    	  &#41;
            &#41;
          &#40;setq whatlength &#40;1- whatlength&#41;&#41;
        &#41;
      &#41;
      ;&#40;redraw &#40;ssname what 0&#41; 3&#41;
      ;&#40;setq where &#40;getpoint "Select point..."&#41;&#41;
      ;&#40;command "break" what where "@0,0"&#41;
      ;&#40;princ "all done"&#41;
      ;&#40;princ&#41;
    &#41;
    Thalon

Bookmarks

Posting Permissions

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