Author Topic: Help to complete my routine...  (Read 5094 times)

0 Members and 1 Guest are viewing this topic.

antistar

  • Guest
Re: Help to complete my routine...
« Reply #15 on: September 24, 2012, 02:25:04 PM »
Not to detract from kruuger's excellent dynamic block work, but here is a very simple way to code it:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:mybox ( / a b p1 p2 )
  2.     (if (and
  3.             (setq a (getpoint "\nSpecify first corner: "))
  4.             (setq b (getcorner a "\nSpecify opposite corner: "))
  5.         )
  6.         (progn
  7.             (setq p1 (mapcar 'min a b)
  8.                   p2 (mapcar 'max a b)
  9.             )
  10.             (mypbox p1 p2)
  11.             (mypbox (mapcar '- p1 '(3 3)) (mapcar '+ p2 '(3 3)))
  12.             (mytext (list (+ (car p2) 13) (- (cadr p1) 28)) "BOX1")
  13.             (mytext (list (+ (car p2) 13) (- (cadr p1) 45))
  14.                 (strcat (rtos (- (car p2) (car p1))) " x " (rtos (- (cadr p2) (cadr p1))))
  15.             )
  16.         )
  17.     )
  18.     (princ)
  19. )
  20.  
  21. (defun mypbox ( a b )
  22.     (entmakex
  23.         (list
  24.            '(0 . "LWPOLYLINE")
  25.            '(100 . "AcDbEntity")
  26.            '(100 . "AcDbPolyline")
  27.            '(90 . 4)
  28.            '(70 . 1)
  29.             (list 10 (car a) (cadr a))
  30.             (list 10 (car b) (cadr a))
  31.             (list 10 (car b) (cadr b))
  32.             (list 10 (car a) (cadr b))
  33.         )
  34.     )
  35. )
  36.        
  37. (defun mytext ( p s )
  38.     (entmakex
  39.         (list
  40.            '(0 . "TEXT")
  41.             (cons 10 p)
  42.             (cons 07 (getvar 'textstyle))
  43.             (cons 40 (getvar 'textsize))
  44.             (cons 01 s)
  45.         )
  46.     )
  47. )

Lee,
 Thanks for your code.
 Just would like to enter the dimensions of the box.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: Help to complete my routine...
« Reply #16 on: September 24, 2012, 02:25:18 PM »
Good code examples Lee & Tharwat.  :-)

Thanks CAB ,  8-)

@Anistar .

I did not get what you mean by your request , can you please clarify it more ?

Quote
I would add the option to enter the box by 5 points in CCW.

antistar

  • Guest
Re: Help to complete my routine...
« Reply #17 on: September 24, 2012, 02:32:12 PM »
Good code examples Lee & Tharwat.  :-)

Thanks CAB ,  8-)

@Anistar .

I did not get what you mean by your request , can you please clarify it more ?

Quote
I would add the option to enter the box by 5 points in CCW.

Tharwat,
 Please, see my code in post #1.

kruuger

  • Swamp Rat
  • Posts: 635
Re: Help to complete my routine...
« Reply #18 on: September 24, 2012, 06:07:29 PM »
why not dynamic block ?
kruuger

I do not know how.  :(
attach your drawing here. maybe i can do something.
k.

Thanks kruuger.
try this. during insert the block click CTRL on keyboard to change insertion point.
kruuger

EDIT: try again. now it's a little better

Kruuger,
Thanks a lot for your attention and work.
Dynamic Blocks not serve because I need to move the texts sometimes.
I prefer to create a LISP with simple texts without attributes, as I described in the first post.
If you can help me would be very grateful.
still can be acheive with dynamic block.
added visibility to turn on/off text.
added move action to change location of text.
is it ok ?
kruuger


Kruuger,
Excellent work.
Thanks a lot for your help.
you welcome. you can always explode block if you want to change something else.
k.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Help to complete my routine...
« Reply #19 on: September 25, 2012, 08:43:36 AM »
Lee,
 Thanks for your code.
 Just would like to enter the dimensions of the box.

You're welcome.
You can enter the dimensions at the getcorner prompt :-)

Good code examples Lee & Tharwat.  :-)

Cheers Alan  :-)

antistar

  • Guest
Re: Help to complete my routine...
« Reply #20 on: September 26, 2012, 12:42:09 PM »
This ... ?

Code - Auto/Visual Lisp: [Select]
  1. (defun c:Test (/ a b p lw p1 p2 p3)
  2. ;;; Tharwat 24. Sep. 2012 ;;;
  3.   (if (and (setq a (getdist "\n Specify length of Box :"))
  4.            (setq b (getdist "\n Specify width of Box :"))
  5.            (setq p (getpoint "\n Specify Left Bottom corner of Box :"))
  6.       )
  7.     (progn
  8.       (setq
  9.         lw (entmakex (list '(0 . "LWPOLYLINE")
  10.                            '(100 . "AcDbEntity")
  11.                            '(100 . "AcDbPolyline")
  12.                            '(70 . 1)
  13.                            '(90 . 5)
  14.                            '(62 . 6)
  15.                            (cons 10 p)
  16.                            (cons 10 (setq p1 (polar p 0. a)))
  17.                            (cons 10 (setq p2 (polar p1 (/ pi 2.) b)))
  18.                            (cons 10 (setq p3 (polar p2 pi a)))
  19.                            (cons 10 (polar p3 (* pi 1.5) b))
  20.                      )
  21.            )
  22.       )
  23.       (vl-cmdf "_.offset"
  24.                3
  25.                lw
  26.                (mapcar '(lambda (a b) (/ (+ a b) 2.)) p1 p3)
  27.                ""
  28.       )
  29.       (vl-cmdf "_.chprop" (entlast) "" "color" 3 "")
  30.       (entmakex
  31.         (list '(0 . "TEXT")
  32.               (cons 7 (getvar 'textstyle))
  33.               (cons 10 (polar (polar p1 0. 10.) (* pi 1.5) 25.))
  34.               '(1 . "BOX1")
  35.               '(40 . 10.)
  36.         )
  37.       )
  38.       (entmakex
  39.         (list '(0 . "TEXT")
  40.               (cons 7 (getvar 'textstyle))
  41.               (cons 10 (polar (polar p1 0. 10.) (* pi 1.5) 40.))
  42.               (cons 1 (strcat (rtos a 2) " x " (rtos b 2)))
  43.               '(40 . 10.)
  44.         )
  45.       )
  46.     )
  47.     (princ)
  48.   )
  49.   (princ)
  50. )

Hi Tharwat,
I have one last request for this routine.
There are changing for the program to run also in UCS NonWorld?