Author Topic: How to insert block "flat to screen" (regardless of 3D view)  (Read 2237 times)

0 Members and 1 Guest are viewing this topic.

kruuger

  • Swamp Rat
  • Posts: 637
hello,

is there any way to insert block "'flat to screen" ?
now my code insert block at any ucs. i want to put them like on second picture.

any trick to do that ?

thanks
kruuger
Code - Auto/Visual Lisp: [Select]
  1. (defun c:TEST (/ sc)
  2.   (setq sc (* (getvar "VIEWSIZE") 0.5))
  3.     (vlax-3d-point (trans (getpoint "\nSelect insertion point: ") 1 0))
  4.     (progn
  5.       (entmakex (list (cons 0 "BLOCK") (cons 2 "*U") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 70 1)))
  6.       (entmake
  7.         (mapcar (quote cons)
  8.          '(0 100 67 8 62 100 90 70 38 10 40 41 10 40 41 10 40 41 210)
  9.          '("LWPOLYLINE" "AcDbEntity" 0 "0" 4 "AcDbPolyline" 3 0 0.0
  10.             (0.0 0.0) 0.02 0.02 (0.0 0.5) 0.33 0.0 (0.5 0.5) 0.0 0.0 (0.0 0.0 1.0)
  11.           )
  12.         )
  13.       )
  14.       (entmake
  15.         (mapcar (quote cons)
  16.          '(0 100 67 8 62 100 90 70 38 43 10 42 10 42 10 42 210)
  17.          '("LWPOLYLINE" "AcDbEntity" 0 "0" 4 "AcDbPolyline" 3 0 0.0 0.01
  18.             (0.1 0.0) 1 (-0.1 0.0) 1 (0.1 0.0) 0.0 (0.0 0.0 1.0)
  19.           )
  20.         )
  21.       )
  22.       (entmake
  23.         (mapcar (quote cons)
  24.           (list 0 1 10 40 50)
  25.           (list "TEXT" "sample" (list 0 0.75 0) 0.02 0)
  26.         )
  27.       )
  28.       (entmake (list (cons 0 "ENDBLK") (cons 8 "0")))
  29.     )
  30.     sc sc sc
  31.     (angle (list 0 0 0) (trans (getvar "UCSXDIR") 0 (trans (list 0 0 1) 1 0 T)))
  32.   )
  33. )

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: How to insert block "flat to screen" (regardless of 3D view)
« Reply #1 on: July 24, 2012, 07:15:52 PM »
Try this:

Code - Auto/Visual Lisp: [Select]
  1. (defun c:test ( / n p s )
  2.     (setq s (/ (getvar 'viewsize) 2.0))
  3.     (if
  4.         (and
  5.             (entmake
  6.                '(
  7.                     (0 . "BLOCK")
  8.                     (2 . "*U")
  9.                     (8 . "0")
  10.                     (10 0.0 0.0 0.0)
  11.                     (70 . 1)
  12.                 )
  13.             )
  14.             (entmake
  15.                '(
  16.                     (0 . "LWPOLYLINE")
  17.                     (100 . "AcDbEntity")
  18.                     (100 . "AcDbPolyline")
  19.                     (67 . 0)
  20.                     (8 . "0")
  21.                     (62 . 4)
  22.                     (90 . 2)
  23.                     (70 . 1)
  24.                     (38 . 0.0)
  25.                     (43 . 0.01)
  26.                     (10 0.1 0.0)
  27.                     (42 . 1)
  28.                     (10 -0.1 0.0)
  29.                     (42 . 1)
  30.                     (210 0.0 0.0 1.0)
  31.                 )
  32.             )
  33.             (entmake
  34.                '(
  35.                     (0 . "TEXT")
  36.                     (1 . "Sample")
  37.                     (10 0.0 0.0 0.0)
  38.                     (11 0.0 0.0 0.0)
  39.                     (40 . 0.02)
  40.                     (72 . 1)
  41.                     (73 . 2)
  42.                 )
  43.             )
  44.             (setq n (entmake '((0 . "ENDBLK") (8 . "0"))))
  45.             (setq p (getpoint "\nSpecify Insertion Point: "))
  46.             (setq v (trans (getvar 'viewdir) 1 0 t))
  47.         )
  48.         (entmake
  49.             (list
  50.                '(0 . "INSERT")
  51.                 (cons 002 n)
  52.                 (cons 010 (trans p 1 v))
  53.                 (cons 041 s)
  54.                 (cons 042 s)
  55.                 (cons 043 s)
  56.                 (cons 050 (- (getvar 'viewtwist)))
  57.                 (cons 210 v)
  58.             )
  59.         )
  60.     )
  61.     (princ)
  62. )
« Last Edit: July 25, 2012, 07:38:42 AM by Lee Mac »

kruuger

  • Swamp Rat
  • Posts: 637
Re: How to insert block "flat to screen" (regardless of 3D view)
« Reply #2 on: July 25, 2012, 04:13:02 AM »
Hi Lee,

almost perfect. is it possible to insert block at point where we select them ?
at least we can move created block to this position.

I would like to make our company hired a programmer to speed up some work.
you will be the first on the list :)

shortly i will send you a small "gift"  :wink:

thanks
kruuger

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: How to insert block "flat to screen" (regardless of 3D view)
« Reply #3 on: July 25, 2012, 07:31:48 AM »
almost perfect. is it possible to insert block at point where we select them ?
at least we can move created block to this position.

Sorry kruuger, I'm not sure that I understand - is the block not currently being inserted at the selected point?

EDIT: After some more testing, you are right - I shall look to fix this for you.

I would like to make our company hired a programmer to speed up some work.
you will be the first on the list :)

shortly i will send you a small "gift"  :wink:

Many thanks Kruuger, that's very kind of you, I appreciate it  :-)
« Last Edit: July 25, 2012, 07:35:23 AM by Lee Mac »

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: How to insert block "flat to screen" (regardless of 3D view)
« Reply #4 on: July 25, 2012, 07:38:59 AM »
Updated above code.

kruuger

  • Swamp Rat
  • Posts: 637
Re: How to insert block "flat to screen" (regardless of 3D view)
« Reply #5 on: July 25, 2012, 04:14:02 PM »
Updated above code.
pure magic. PERFECTO !!!

Thanks  :lol:
kruuger

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: How to insert block "flat to screen" (regardless of 3D view)
« Reply #6 on: July 25, 2012, 06:18:53 PM »
pure magic. PERFECTO !!!

Thanks  :lol:
kruuger

Excellent :)

You're very welcome Kruuger, enjoy  8-)