Ref my problem of a few days ago, I have now finished the development and
the utility is working fine. The key to keeping performance up when
working with large datasets is to read the object you wish to use as the
cutter into a memory variable rather than using it directly from the
cosmetic layer.
My thanks to Phil Gee and Peter Horsb�ll M�ller for their responses which
pointed me in the right direction.
And here for those of you who are interested is a stripped down version of
the completed app. The utility allows you to draw any shape on the screen,
select it and then export all objects in the shape to a single dxf file.
Apologies for any naff programming, efficient coding was never my strong
point!!
Regards
Owen
UK
declare sub main
INCLUDE "MAPBASIC.DEF"
INCLUDE "MENU.DEF"
DIM SELECT_SHAPE AS OBJECT
DIM SELECT_ALIAS,SELECT_TABLE_OBJ AS ALIAS
DIM QUERY_NAME,SELECT_TABLE,DXF_FILE_NAME AS STRING
DIM I,J AS INTEGER
sub main
IF SELECTIONINFO(SEL_INFO_NROWS) = 0 THEN
NOTE "Exporting to DXF:"+CHR$(10)+
"Draw a shape (rectangle, ellipse or polygon) on screen, "
+CHR$(10)+
"select the shape by clicking on it. Then rerun this
utility"
EXIT SUB
END IF
IF SELECTIONINFO(SEL_INFO_NROWS) >1 THEN
NOTE "Exporting to DXF:"+CHR$(10)+
"Select just one object and rerun this utility"
END IF
'Display dialog box for user to enter dxf filename and location
DXF_FILE_NAME=FILESAVEASDLG("","DXFCOPY","DXF","Enter name for DXF
File")
IF DXF_FILE_NAME="" THEN
'No file name selected from dialog box so exit sub routine
EXIT SUB
END IF
'Get first (and only record) from selection and store that object to
'an object variable for use within the select
FETCH FIRST FROM SELECTIONINFO(SEL_INFO_SELNAME)
SELECT_ALIAS=SELECTIONINFO(SEL_INFO_SELNAME)+".OBJ"
SELECT_SHAPE=SELECT_ALIAS
'Suppress display of progress bars during export
SET PROGRESSBARS OFF
'*** Stage 1 is to loop through until we find a table that selects at
least one
'*** record falling within the object drawn on screen -
'*** This will act as the base table to append all subesequent queries
to
'***
FOR I=1 TO MAPPERINFO(FRONTWINDOW(),MAPPER_INFO_LAYERS)
'***
'*** Check current layer is selectable (ignore if not)
'***
IF LAYERINFO(FRONTWINDOW(),I,LAYER_INFO_SELECTABLE)=TRUE THEN
'Table name / Table object Column
SELECT_TABLE=LAYERINFO(FRONTWINDOW(),I,LAYER_INFO_NAME)
SELECT_TABLE_OBJ=LAYERINFO(FRONTWINDOW(),I,LAYER_INFO_NAME)
+".OBJ"
'***********
SELECT SELECT_TABLE_OBJ FROM SELECT_TABLE WHERE
SELECT_TABLE_OBJ INTERSECTS SELECT_SHAPE
'***********
IF SELECTIONINFO(SEL_INFO_NROWS)>0 THEN
QUERY_NAME=SELECTIONINFO(SEL_INFO_SELNAME)
COMMIT TABLE QUERY_NAME AS "C:\TEMP\TEMPSEL.TAB"
CLOSE TABLE QUERY_NAME
EXIT FOR
END IF
END IF
NEXT
'*** Stage two is to loop round remaining tables appending the
selection to the
'*** table defined above
IF I<MAPPERINFO(FRONTWINDOW(),MAPPER_INFO_LAYERS) THEN
'There are some layers left that may have objects in
OPEN TABLE "C:\TEMP\TEMPSEL.TAB"
FOR J=I+1 TO MAPPERINFO(FRONTWINDOW(),MAPPER_INFO_LAYERS)
'***
'*** Check current layer is selectable (ignore if not)
'***
IF LAYERINFO(FRONTWINDOW(),J,LAYER_INFO_SELECTABLE)=TRUE
THEN
SELECT_TABLE=LAYERINFO(FRONTWINDOW(),J,LAYER_INFO_NAME)
SELECT_TABLE_OBJ=LAYERINFO(FRONTWINDOW
(),J,LAYER_INFO_NAME)+".OBJ"
'***********
SELECT SELECT_TABLE_OBJ FROM SELECT_TABLE WHERE
SELECT_TABLE_OBJ INTERSECTS SELECT_SHAPE INTO QQRST
'
IF SELECTIONINFO(SEL_INFO_NROWS)>0 THEN
INSERT INTO TEMPSEL
SELECT * FROM QQRST
CLOSE TABLE QQRST
END IF
END IF
NEXT
'Save temporary table which now contains all objects from all
layers
'that fall within object draw
COMMIT TABLE TEMPSEL
'Export table to DXF
EXPORT TEMPSEL INTO DXF_FILE_NAME TYPE DXF OVERWRITE
'Delete temporary tables
' CALL TIDYUPDXF
'Unselect all
RUN MENU COMMAND M_QUERY_UNSELECT
'Check newly created DXF file exists in right place and display
message
IF FILEEXISTS(DXF_FILE_NAME) THEN
NOTE "Successfully created DXF File "+DXF_FILE_NAME
ELSE
NOTE "DXF File "+DXF_FILE_NAME+" not created - Error"
END IF
ELSE
'No objects found within shape drawn on screen
NOTE "No objects found within shape drawn"
END IF
'Reactivate progress bars
SET PROGRESSBARS ON
end sub
_______________________________________________________________________
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, send e-mail to [EMAIL PROTECTED] and
put "unsubscribe MapInfo-L" in the message body.