Author Topic: Entmake a Wipeout in rotated WCS ?  (Read 10653 times)

0 Members and 1 Guest are viewing this topic.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Entmake a Wipeout in rotated WCS ?
« on: January 24, 2013, 02:28:34 PM »
Trying to Entmake a Wipeout in rotated WCS.
Using this to rotate the space
^C^Cdview;;tw;90;;_ucs;w;_ucs;z;270;

Trying to create a rectangular wipeout 1.5 wide & 37.0 tall
This works in WCS but not in the rotated CS
Code: [Select]
        (entmake (list '(0 . "WIPEOUT") '(100 . "AcDbEntity")
                   (cons 8  defLayer)
                   '(62 . 4) ; color
                   '(100 . "AcDbWipeout") '(90 . 0)
                   (cons 10 (trans pll 1 0))
                   (list 11 37.0 0.0 0.0) 
                   (list 12 0.0 37.0 0.0) 
                   '(13 1.0 1.0 0.0) '(70 . 7) '(280 . 1) '(281 . 50) '(282 . 50) '(283 . 0) '(71 . 2) '(91 . 5)
                   '(14 -0.5 0.5 0.0) '(14 -0.5 -0.5 0.0) '(14 -0.459459 -0.5 0.0) '(14 -0.459459 0.5 0.0)
                   '(14 -0.5 0.5 0.0))
                   )

Looked at these post but both do not produce the correct results.
http://goo.gl/KEiTe
http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/Entmake-2004-wipeout/td-p/1810662#
The second link has a correction at the end by Guile but still doesn't work correctly.

Any insight into this OCS problem would be appreciated.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Entmake a Wipeout in rotated WCS ?
« Reply #1 on: January 24, 2013, 04:35:34 PM »
Try this Alan:

Code: [Select]
(defun c:test ( / p ) 
    (if (setq p (getpoint "\nInsertion Point: "))
        (entmake
            (list
               '(000 . "WIPEOUT")
               '(100 . "AcDbEntity")
               '(100 . "AcDbWipeout")
                (cons 10 (trans p 1 0))
                (cons 11 (trans '(37.0 0.0) 1 0))
                (cons 12 (trans '(0.0 37.0) 1 0))
               '(280 . 1)
               '(071 . 1)
               '(014 -0.50 -0.5)
                (list 14 (/ 17.0 -37.0) 0.5)
            )
        )
    )
)
« Last Edit: January 24, 2013, 05:11:52 PM by Lee Mac »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #2 on: January 24, 2013, 05:54:17 PM »
Thanks that worked.  8-)

What is the dxf 14 relationship with the object?
(/ 17. -37.) ???
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Entmake a Wipeout in rotated WCS ?
« Reply #3 on: January 24, 2013, 07:08:13 PM »
Thanks that worked.  8-)

 :-)

What is the dxf 14 relationship with the object?(/ 17. -37.) ???

Sorry, my fraction simplification may have obscured the intent:

  (1.5 / 37) - 0.5
= (3/2)*(1/37) - 1/2
=  3/74 - 37/74
= -17/37

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #4 on: January 24, 2013, 08:24:15 PM »
Thanks Lee, I have some more rectangles to build.
That will help.  8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Wipeout Coordinate System
« Reply #5 on: January 24, 2013, 08:42:42 PM »
To further explain...

The WIPEOUT entity uses the same DXF Groups as an IMAGE entity, however, rather than having an image composed of thousands of pixels, a wipeout uses only a single pixel of the image.

When we provide the values for DXF Groups 11 & 12, we are specifying the X & Y vectors for the 'Pixel Coordinate System'.

For an IMAGE entity, the length of these vectors would be the number of units in modelspace spanned by a single pixel of the image; for a WIPEOUT entity, we are only using a single pixel, hence the length of these vectors is equal to the largest dimension of the bounding box of the wipeout (since each pixel must be square) -  in this case, 37 x 37.

Hence the vectors for the X & Y axes of the pixel coordinate system are (37.0 0.0) & (0.0 37.0); this equates to (1.0 0.0) & (0.0 1.0) under the pixel coordinate system.

We can then use the trans function to account for a rotated UCS and transform these axis vectors accordingly; the way I visualise this is: "What does the UCS vector (37.0 0.0) look like in WCS?" - the answer: (trans '(37.0 0.0) 1 0) - resulting in a WCS axis vector rotated in accordance with the UCS.

Having defined the size and orientation of the pixel coordinate system we have a coordinate system represented by the following diagram:



The origin of this coordinate system is the centre of the pixel, with the positive X-axis direction to the right, and positive Y-axis direction to the base (don't ask me why Autodesk implemented it in reverse...)

The wipeout insertion point (DXF Group 10) is located in the bottom-left corner of this system, i.e. at (-0.5, 0.5).

Each of the DXF Group 14 values are now expressed relative to this pixel coordinate system, as shown in the following diagram with your example wipeout displayed:



Since your wipeout was rectangular, we only needed to specify two corner points to define the wipeout: (-0.5, -0.5) [top-left corner] & (-0.5+1.5/37, 0.5) [bottom-right corner]

Note that we could have equally used: (-0.5, 0.5) [bottom-left corner] & (-0.5+1.5/37, -0.5) [top-right corner]; however, (-0.5, -0.5) is the default initial rectangular coordinate.

Notice also that to calculate the correct width for the wipeout we have use 1.5/37 since the 'pixel' has a width of 37 modelspace units, and we need to calculate the fraction represented by 1.5 units out of 37 (since the pixel has width 1).

If the wipeout were to be polygonal rather than rectangular, DXF Group 71 would need to be changed to 2, and every vertex of the polygon boundary needs to be represented by a DXF Group 14 pixel coordinate.

To calculate these coordinates you would calculate the vector from the centre of the pixel (i.e. the origin) to each vertex and divide the X & Y coordinates of this vector by the size of the pixel (37 in this case), also remembering to negate the Y-coordinate.

I hope this explanation is somewhat clear, but please do ask if you require further clarification and I shall do my best to explain.

Lee

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #6 on: January 24, 2013, 09:58:38 PM »
Great explanation Lee.
I was heading in that direction but this makes for a much clearer picture. (excuse the pun)
Watching tennis with the wifee  :-) so I will give it another read tomorrow.

Thanks for your time. 8-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Entmake a Wipeout in rotated WCS ?
« Reply #7 on: January 25, 2013, 06:43:25 AM »
You're very welcome Alan  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #8 on: January 25, 2013, 07:51:52 AM »
Re reading your post this morning and even though I'm on my first cup it is quite clear what is going on.
They should use your explanation in the HELP manual.  :lol:
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Entmake a Wipeout in rotated WCS ?
« Reply #9 on: January 25, 2013, 08:07:01 AM »
Re reading your post this morning and even though I'm on my first cup it is quite clear what is going on.

Excellent - that's great to hear CAB, I'm glad everything is clear  :-)

They should use your explanation in the HELP manual.  :lol:

lol, what help manual...  :-D

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Wipeout Coordinate System
« Reply #10 on: January 25, 2013, 09:21:36 AM »
If the wipeout were to be polygonal rather than rectangular, DXF Group 71 would need to be changed to 2, and every vertex of the polygon boundary needs to be represented by a DXF Group 14 pixel coordinate.

To calculate these coordinates you would calculate the vector from the centre of the pixel (i.e. the origin) to each vertex and divide the X & Y coordinates of this vector by the size of the pixel (37 in this case), also remembering to negate the Y-coordinate.

For completeness, here is an example of how to create a polygonal wipeout using the method described above:

Code: [Select]
;; Polygonal Wipeout  -  Lee Mac
(defun c:pw ( / c g l m p )
    (if (car (setq l (list (getpoint "\nFirst Point: "))))
        (progn
            (princ "\nNext Point: ")
            (while
                (progn
                    (while (= 5 (car (setq g (grread t 13 0))))
                        (redraw)
                        (mapcar '(lambda ( a b ) (grdraw a b 1)) (cons (cadr g) l) (append l (cdr g)))
                    )
                    (if (= 3 (car g))
                        (setq l (cons (cadr g) l))
                    )
                )
            )
            (redraw)
            (setq l (cons (last l) l)
                  p (apply 'mapcar (cons 'min l))
                  m (apply 'max (mapcar '- (apply 'mapcar (cons 'max l)) p))
                  c (mapcar '+ p (list (/ m 2.0) (/ m 2.0)))
            )
            (entmake
                (append
                    (list
                       '(000 . "WIPEOUT")
                       '(100 . "AcDbEntity")
                       '(100 . "AcDbWipeout")
                        (cons 10 (trans p 1 0))
                        (cons 11 (trans (list m 0.0) 1 0))
                        (cons 12 (trans (list 0.0 m) 1 0))
                       '(280 . 1)
                       '(071 . 2)
                    )
                    (mapcar
                        (function
                            (lambda ( x )
                                (cons 14 (mapcar '(lambda ( a b c ) (/ (- a b) c)) x c (list m (- m))))
                            )
                        )
                        l
                    )
                )
            )
        )
    )
    (princ)
)

The above should also work in all UCS & Views.  :-)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #11 on: January 27, 2013, 09:10:31 AM »
Perfect Lee, I changed it into a sub function for my use.  Thanks  8-)

Code - Auto/Visual Lisp: [Select]
  1.   ;;  Requires a point list and layer name
  2.   (defun MkWipeout (lst lay / c m p)
  3.     (setq lst (cons (last lst) lst)
  4.           p (apply 'mapcar (cons 'min lst))
  5.           m (apply 'max (mapcar '- (apply 'mapcar (cons 'max lst)) p))
  6.           c (mapcar '+ p (list (/ m 2.0) (/ m 2.0)))
  7.     )
  8.     (entmakex
  9.       (append
  10.         (list
  11.           '(000 . "WIPEOUT")
  12.           '(100 . "AcDbEntity")
  13.           '(100 . "AcDbWipeout")
  14.           (cons 8 lay)
  15.           (cons 10 (trans p 1 0))
  16.           (cons 11 (trans (list m 0.0) 1 0))
  17.           (cons 12 (trans (list 0.0 m) 1 0))
  18.           '(280 . 1)
  19.           '(071 . 2)
  20.         )
  21.         (mapcar
  22.           (function
  23.             (lambda (x)
  24.               (cons 14 (mapcar '(lambda (a b c) (/ (- a b) c)) x c (list m (- m)))))) lst)))
  25.    )
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

VovKa

  • Water Moccasin
  • Posts: 1631
  • Ukraine
Re: Entmake a Wipeout in rotated WCS ?
« Reply #12 on: January 27, 2013, 05:16:17 PM »
why do you guys use wipeouts? i always thought that white hatches are more convenient and easier to handle.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Entmake a Wipeout in rotated WCS ?
« Reply #13 on: January 27, 2013, 06:56:39 PM »
Just started using them recently. My stair and hand rail lisp uses them because breaking all the objects behind is too time consuming.
And when something has to be moved the breaking starts all over again.

That being said I have not tried hatching all those rectangles. The railing and the pickets and the stringers are all wipeouts.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

bchapman

  • Guest
Re: Entmake a Wipeout in rotated WCS ?
« Reply #14 on: January 29, 2013, 12:07:16 AM »
Both are interesting approaches. How does the wipeout work?   Hatching might be more efficient... could isolate objects and simply hatch the entire group...draw order as needed.