+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17

Thread: Box Lisp

  1. #1
    Senior Member neekcotrack's Avatar
    Using
    MEP 2009
    Join Date
    May 2008
    Location
    Florida
    Posts
    329

    Default Box Lisp

    Registered forum members do not see this ad.

    I was wondering does anyone know of a lisp that will:

    1. Ask for the width and height of a box.
    2. Then ask if it is low volage or hight voltage. If it is low voltage go to next step, if it is high voltage hatch the box.
    3. insert the box using the (getvar "dimscale") and pick the long sides midpoint for insertion point.
    4. Use users insertion point and rotation.

    Thanks in advance for any help that I can get I don't know how to do lisp but I can do diesel Macros.

  2. #2
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Not sure this is exactly what you want
    Give this a try, just translate all the prompts
    on good english

    Code:
    (defun rtd (a)
      (* 180.0 (/ a pi))
    )
    (defun C:VB (/ ang flag hgt p1 p2 pt response wid)
      
      (setq osm (getvar "osmode"))
      (setvar "osmode" 0)
      (setq ort (getvar "orthomode"))
      (setvar "orthomode" 0)
      
      (while
      (setq wid (getdist "\nEnter the width of box (or press Enter to exit): "))
      (setq hgt (getdist  "\nEnter the height of box: "))
      (if (and wid hgt)
        (progn
          (setq flag nil)
          (initget 1 "Low Heigh")
          (setq response (getkword "\nChoose voltage level [L]ow or [H]eigh <L> : "))
          (if (eq "Heigh" response)(setq flag t))
          	  (setq pt (getpoint "\nInsertion point (bottom center): "))
    	  (setq p1 (list (- (car pt)(/ wid 2.))(cadr pt))
    		p2 (list (+ (car pt)(/ wid 2.))(+ (cadr pt) hgt))
    		)
          	  (command "rectangle" p1 p2)
    	  (setq ang (getangle pt "\nSpecify rotation angle: "))
    	  (command "rotate" "L" "" pt (rtd ang))
          (if flag
    	(command "-hatch" "S" "L" "" "P" "S" "")
    
    	  )
    	  )
          )
    )
      (setvar "orthomode" ort)
      (setvar "osmode" osm)
      (princ)
      )
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  3. #3
    Senior Member neekcotrack's Avatar
    Using
    MEP 2009
    Join Date
    May 2008
    Location
    Florida
    Posts
    329

    Default

    Its just what I was looking for but one thing. When I am prompted to clock where I want to place it, once I place it i was wondering if there is a way to let you selected the rotation by another point on the screen then typing it in. Is there a way to use ansi31 as my pattern and the scale of the pattern to be 18.

    Thanks for everything by the way.

  4. #4
    Senior Member neekcotrack's Avatar
    Using
    MEP 2009
    Join Date
    May 2008
    Location
    Florida
    Posts
    329

    Default

    If possible can you make the pattern rotation angle to be the angle the block is so the hatch is always at 45

  5. #5
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Hope I added all what you need:

    Code:
    (defun C:VB (/ ang flag hgt osm p1 p2 pt response wid)
      
      (setq osm (getvar "osmode"))
      (setvar "osmode" 0)
    
      
      (while
      (setq wid (getdist "\nEnter the width of box (or press Enter to exit): "))
      (setq hgt (getdist  "\nEnter the height of box: "))
      (if (and wid hgt)
        (progn
          (setq flag nil)
          (initget 1 "Low Heigh")
          (setq response (getkword "\nChoose voltage level [L]ow or [H]eigh <L> : "))
          (if (eq "Heigh" response)(setq flag t))
          	  (setq pt (getpoint "\nInsertion point (bottom center): "))
    	  (setq p1 (list (- (car pt)(/ wid 2.))(cadr pt))
    		p2 (list (+ (car pt)(/ wid 2.))(+ (cadr pt) hgt))
    		)
          	  (command "rectangle" p1 p2)
    	  (setq ang (getreal "\nSpecify rotation angle (in degrees): "))
    	  (command "rotate" "L" "" pt ang)
          (if flag
    	(command "-hatch" "S" "L" "" "P" "ANSI31" "18" "45" "");<==45 is an angle for the pattern, change to suit
    	  )
    	  )
          )
    )
    
      (setvar "osmode" osm)
      (princ)
      )
    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  6. #6
    Senior Member neekcotrack's Avatar
    Using
    MEP 2009
    Join Date
    May 2008
    Location
    Florida
    Posts
    329

    Default

    ok just one thing left I am so sorry. Is there any way to scale it to the dimscale. what I type in for the width and height is what it would be at 1. Now if it is at eigth scale it would be a dimscale of 96. Is there any way to do that?

    Thanks for everything you helped greatly!

  7. #7
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Embarrassed

    I don't understand what are you talking about
    Try to change dimscale:
    (setvar "dimscale" 96)

    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  8. #8
    Senior Member neekcotrack's Avatar
    Using
    MEP 2009
    Join Date
    May 2008
    Location
    Florida
    Posts
    329

    Default

    I want it to scale up depending on the dimscale!

  9. #9
    Super Member fixo's Avatar
    Computer Details
    fixo's Computer Details
    Operating System:
    Windows 7
    Motherboard:
    E7500
    CPU:
    Intel(R)Core(TM)2 DUO CPU 2.93HGz
    RAM:
    4098 Gb
    Graphics:
    1024 Gb
    Using
    AutoCAD 2009
    Join Date
    Jul 2005
    Location
    Pietari, Venäjä
    Posts
    1,587

    Default

    Sorry,
    perhaps somebody else will be able
    to help you with this problem

    ~'J'~
    The soul is healed by being with children. - Fyodor Dostoyevsky, novelist (1821-1881)

  10. #10
    Senior Member
    Using
    Civil 3D 2008
    Join Date
    Feb 2008
    Posts
    294

    Default

    Registered forum members do not see this ad.

    Mean something like this??

    Code:
    (defun C:VB (/ ang flag hgt osm p1 p2 pt response wid)
      
      (setq osm (getvar "osmode"))
      (setvar "osmode" 0)
      
      (while
      (setq wid1 (getdist "\nEnter the width of box (or press Enter to exit): "))
      (setq wid (* wid1 (getvar "dimscale")))
      (setq hgt1 (getdist  "\nEnter the height of box: "))
      (setq hgt (* hgt1 (getvar "dimscale")))
      (if (and wid hgt)
        (progn
          (setq flag nil)
          (initget 1 "Low Heigh")
          (setq response (getkword "\nChoose voltage level [L]ow or [H]eigh <L> : "))
          (if (eq "Heigh" response)(setq flag t))
             (setq pt (getpoint "\nInsertion point (bottom center): "))
       (setq p1 (list (- (car pt)(/ wid 2.))(cadr pt))
      p2 (list (+ (car pt)(/ wid 2.))(+ (cadr pt) hgt))
      )
             (command "rectangle" p1 p2)
       (setq ang (getreal "\nSpecify rotation angle (in degrees): "))
       (command "rotate" "L" "" pt ang)
          (if flag
     (command "-hatch" "S" "L" "" "P" "ANSI31" "18" "45" "");<==45 is an angle for the pattern, change to suit
       )
       )
          )
    )
      (setvar "osmode" osm)
      (princ)
      )

Similar Threads

  1. problem, trying to running a list of lisp from within a lisp
    By twind2000 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 20th Aug 2007, 04:27 pm
  2. calling another lisp from within my lisp
    By thalon in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 22nd Feb 2006, 09:56 pm

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