Code Red > AutoLISP (Vanilla / Visual)

Examples of usage GRREAD - let's share

<< < (2/55) > >>

sinc:

--- Quote from: MickD on October 08, 2006, 06:56:36 PM ---
You can see now how complex it could get if you tried to capture pixels in any direction but 'square' to the screen.
A work around could be to grab the rectangle and the model/scene and transform it to be square, do the selection thing and invert it back but there may be some subtle inaccuracies with doing this not to mention a performance hit.

--- End quote ---

Are you really sure about all this, or is it a lot of guesswork?

You can always type WP or CP at the "Select Objects" prompt, and select any irregular selection area you want.  The selection area can be pretty convoluted.  If it's possible to easily select any irregular area like that, why would it be any harder to create a rectangular box oriented with, say, the SNAPANG?

ElpanovEvgeniy:

--- Quote from: Crank on October 08, 2006, 02:38:53 PM ---
Do you mean GRREAD or GRDRAW? :D


--- End quote ---

I meant GRREAD!
Actually, it can be used in greater quantity cases, than it is done by me....
I would like to see various variants of application :-)

GDF:
Not sure of this one, I think it uses grread...anyway it is a kool routine.

..google it..


--- Code: ---
                                K4KUBE.TXT
                                ==========

                      Freeware Version 1.01 of K4KUBE

                   Copyright (C) 2002,  K4 CAD Solutions


WELCOME TO K4KUBE
===============================================================================

K4KUBE is a free RUBIK'S CUBE game for AutoCAD (R12, R13, R14, 2000, 2002).

K4KUBE comes as a zipped file (A_RUBIX.ZIP) which unzips into two files:

K4KUBE.TXT  - This File.
K4KUBE.LSP  - An AutoLISP program to play
              R U B I K ' S   C U B E.


INSTALLING K4KUBE
===============================================================================

1) Create a new directory with the path C:\K4KUBE (or any other name).
2) Unzip A_RUBIX.ZIP which expands into the two files listed above.


RUNNING K4KUBE
===============================================================================

Using the AutoCAD Menus, select 'Tools', then 'Load Application...', then
select K4KUBE.LSP from the folder which you installed into. Click on
'Load' then verify that it loaded successfully.

OR,  at the AutoCAD command prompt type:

     (load "c:/k4kube/k4kube")     [Note: use forward slashes].

     If you have installed K4KUBE into a different directory or folder than
     the one above, eg. C:\Program Files\K4kube then type:

     (load "c:/program files/k4kube/k4kube")

OR,  for easier loading copy the file K4KUBE.LSP somewhere into the AutoCAD
     support path and then type:

     (load "k4kube")

Alternatively, the AutoLISP File K4KUBE.LSP may be loaded by double clicking
on it via Windows Explorer.


Once loaded, the command K4KUBE runs automatically.

Click on Large Arrows to turn the cube.
Click on Small Arrows to turn a layer.
Click on buttons to:  MIX  (10 random twists)
                      SORT (resets cube)
                      QUIT (quits K4KUBE, remembers last permutation)
The command K4KUBE be run at any time from the Command Bar.


NOTE: If running in IntelliCAD type:

     (setq k4icad 1)

      at the command prompt.

  OR,

      Create a new file called 'K4KUBE-P.LSP' containing:

      (setq k4icad 1)
      (load "c:/k4kube/k4kube")  ;;modify to your installation path

      Finally, to run K4KUBE type:

      (load "c:/k4kube/k4kube-p")


ABOUT K4 CAD SOLUTIONS
===============================================================================

K4 CAD Solutions develops bespoke software for AutoCAD (and Windows) to meet
very specific user-requirements that are often not fully addressed by 'off
the shelf packages'.  Examples of the types of projects undertaken include:

     Parametric Commands : Commands to automate the drawing of complicated
                           designs simply by specifying dimensions of the
                           features within the design.  Use of dialogue boxes
                           enables fast and accurate data entry.

 Manufacturers Databases : Suites of commands that interactively display then
                           insert your company's manufactured products into
                           drawings - for use in-house or for distribution to
                           engineers, architects and specifiers.

     CNC Code Generators : Commands to draw machined parts and automatically
                           generate CNC code to your exact specifications.
                           G CODE turning and milling projects undertaken.

For more information regarding the services on offer or to discuss your
specific requirements in detail email K4 CAD Solutions at:

                           admin@k4cadsolutions.co.uk

or visit the web site:     http://www.k4cadsolutions.co.uk


       Fixed price quotes offered for well defined and specified projects.
             K4 CAD Solutions is based in Yorkshire, United Kingdom.


WARRANTY STATEMENT
===============================================================================

Author is not responsible for any damages whatsoever, including loss of
information, interruption of business, personal injury and/or any damage or
consequential damage without limitation, incurred before, during or after the
use of this product. Author's entire liability, without exception, is limited to
the customers' reimbursement of the purchase price (if applicable) of the
software (maximum being the suggested retail price) in exchange for the
return of the product, all copies, registration papers and manuals, and all
materials that constitute a transfer of ownership from the customer back to
Author.


LICENSE
===============================================================================

Each registered copy of this software may be used in only one single
location by one user.  Use of the software means that you have loaded the
program and run it or have installed the program onto a computer.  If you
install the software onto a multi-user platform or network, each and every
individual user of the software must be registered separately.

You may make one copy of the registered software for backup purposes,
providing you only have one copy installed on one computer being used by
one person.  If any person other than yourself uses software registered in
your name, regardless of whether it is at the same time or different times,
then this agreement is being violated!

The sale of and or distribution of registered copies of this software are
strictly forbidden.  It is a violation of this agreement to loan, rent,
lease, borrow, or transfer the use of registered copies of this software
product.


            AutoCAD is a registered trademark of Autodesk Inc.
        Windows is a registered tradmark of Microsoft Corporation

===============================================================================
Copyright (C) K4 CAD Solutions, April 2002
===============================================================================

--- End code ---

MickD:

--- Quote from: sinc on October 09, 2006, 09:52:08 AM ---...
Are you really sure about all this, or is it a lot of guesswork?
...

--- End quote ---

The part about how selection is accomplished yes, the accuracy of using irregular selection shapes no. Although it is possible to use irregular shapes it would take multiple passes or some mathematical gymnastics to get the correct primitives for the selection, especially if you had a curved edge in your selection shape.

I'll expand a bit on the selection process as performed by the grfx api for those interested. From here we'll call the host application using the grfx api the 'app' and the graphics api the 'grfx'.
Prior to selection, the app using the selection buffer must change the state of the grfx to 'selection' mode which draws all of the primitives to a special buffer (not to the screen) and gathers all of the objects drawn there.
Here's the process just using the std acad pickbox (cursor) which is about 4x4 pixels say -

1. The user picks a line say which sends a WM_MOUSEDOWN message, the app's window procedure catches and handles it appropriately. Depending on the state of the application it can handle this how it pleases, for now we'll say it is idle and will handle selection to highlight entities picked with the cursor in the editor (the client area of the main window where the grfx will draw its primitives).

2. Having caught the message the app has to tell the grfx it wants to do a sellection of the picked object. To do this the app must set the 'state' of the graphics to selection to draw to the selection buffer. To draw to this buffer (just like any other window) the app has to pass in of its viewing transformation, which also contains the view/model and clipping volume and finally maps this to a rectangle on the screen, generally the x and y size of our client rectangle/editor. In the case of the selection buffer we only want what's under the cursor so we pass in the x and y size of the 'pick box', the app assigns an id to each primitive (using named lists in the grfx) before it's drawn which the grfx uses to identify the drawn primitives. The grfx then draws the objects to the selection buffer, grabs a list of the ids it has drawn after 'clipping' and passes this list/array back to the app.
How does it get the id's? As the grfx has to calculate the colour of each pixel it draws to the buffer, in the selection mode it also assigns an id of each drawn primitive to each pixel within the selection rectangle/buffer, when you do a 'pick' or even a windowed selection you are just picking a rectangle/box of pixels and use the info store in the buffer mapped to that pixel.

3. On receiving the 'hit list' of objects drawn to the selection buffer (remembering the selection rect clips out all unwanted geometry outside of the rect passed in) the app iterates the list and handles it how it pleases, in Autocad's case it calls the ent->highlight() member function of the/each selected entity to tell it to draw itself highlighted. The app then redraws the scene in the normal rendering mode passing in all of the entities and now the ent's to be highlighted with the appropriate primitive line type to appear highlighted.

For autocad to use irregular selection with a polyline say, it would almost have to be only in 2d to keep the math simple and it would not need to use the selection buffer of the grfx, if it can do it with a 3d model (items that don't cross the polyline in the same plane) it would have to be doing its own projections to the polyline plane and then the clipping. Basically though the selction buffer is the most efficient way to collect selected entities IMO as this is what it is used and optimised for.

Cheers,
Mick.



sinc:

--- Quote from: MickD on October 09, 2006, 06:52:09 PM ---
For autocad to use irregular selection with a polyline say, it would almost have to be only in 2d to keep the math simple and it would not need to use the selection buffer of the grfx, if it can do it with a 3d model (items that don't cross the polyline in the same plane) it would have to be doing its own projections to the polyline plane and then the clipping. Basically though the selction buffer is the most efficient way to collect selected entities IMO as this is what it is used and optimised for.


--- End quote ---

Autocad can in fact select anything, in full 3D, with irregular windows.  But I notice that irregular windows can also select things that are not visible on the screen, while the normal rectangular windows cannot.  So this seems to imply that Autocad uses the grfx for normal windows, but does its own model parsing for irregular windows.  I don't notice any performance difference between the two, but I'm guessing I might with a much bigger drawing or with slower hardware.

In either case, the objects appear to be projected in into the plane of the current view to determine what gets selected.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version