/* autodxfarc.aml /* /* Version: 7.0.3 /* Called by: dxfarc.menu /* Calls made: users DXF file.menu /* msg.menu /* /* Description: An automatic method of converting a DXF file to a cover /* eliminating the need for the user to perform a DXFINFO /* where all layers and any possible options appear in a menu /* for the user to select from. Once the menu is created it /* can be accessed for future use, as long as it still /* exists and that it still corresponds to the same DXF file. &args file &severity &warning &ignore &severity &error &routine ERROR &s echo [show &echo] /* Check if menu already exists or does it have to be created &if [exists [entryname %file% -noext].menu -file] &then &do /* Open menu and assign number of DXF layers and DXF layer names to /* variables &s menu [open [entryname %file% -noext].menu openstatus -read] &s x [read %menu% readstatus] &s x [read %menu% readstatus] &s layers 0 &do &until [null %line%] &s layers [calc %layers% + 1] &s line [unquote [read %menu% readstatus]] &if ^ [null %line%] &then &do &s %layers% [extract 2 %line%] &s layer%layers% [extract 2 %line%] &end /* then do &end /* do until &s layers [calc %layers% - 1] &s x [close %menu%] &end /* then do &else &do /* Construct menu for selecting DXF layers to process /* Perform DXFINFO to a watch file &echo &off &mess &off &info &if [exists [entryname %file% -noext].wat -file] &then &s x [delete [entryname %file% -noext].wat -file] &watch [entryname %file% -noext].wat DXFINFO %file% &watch &off &mess &on &echo %echo% /* Open watch file and assign number of DXF layers and DXF layer names /* to variables &s wat [open [entryname %file% -noext].wat openstatus -read] &s line [read %wat% readstatus] &do &until [quote [extract 2 %line%]] eq '----------------' &s line [unquote [read %wat% readstatus]] &end /* do until &s layers 0 &s line [unquote [read %wat% readstatus]] &do &until [quote [extract 2 %line%]] eq '----------------' &s layers [calc %layers% + 1] &s layer%layers% [unquote [subst [quote %line%] ! ' ']] &s line [unquote [read %wat% readstatus]] &end /* do until &s [close %wat%] /* Delete watch file as it is no longer needed &s x [delete [entryname %file% -noext].wat -file] /* Construct menu header, write description and list of DXF layers &s menu [open [entryname %file% -noext].menu openstatus -write] &s x [write %menu% [quote ~ 7 [entryname %file% -noext].menu used to convert DXF files to covers]] &s line [quote [unquote '/*'] Do not delete the following commented lines] &s x [write %menu% %line%] &do a = 1 &to %layers% &by 1 &s line [quote [unquote '/*'] [value layer%a%]] &s x [write %menu% %line%] &end /* do to by /* Construct placement of menu widgets for each DXF layer, and any /* text to appear in menu &s x [write %menu% ' '] &s x [write %menu% ' %0 Convert all DXF entities from all layers'] &s 0 .FALSE. &s x [write %menu% ' '] &s x [write %menu% ' OR ... ~ Select which DXF entites to convert for each layer'] &s x [write %menu% ' '] &s x [write %menu% ' Text as ~ Attributes as'] &s x [write %menu% ' Layer Name Arcs Points Points Anno ~ Points Anno Insert All'] &s x [write %menu% ' ---------------- ------ ------ ------ ------ ~ ------ ------ ------ ------'] &s n 1 &do a = 1 &to %layers% &by 1 &until %a% gt 99 &if %a% lt 10 &then &s line ' %'%a%' ' &else &s line ' %'%a%' ' &s line%n% '%'%a%' display '%a%' 16 value' &s %a% [extract 1 [value layer%a%]] &s n [calc %n% + 1] &s b 2 &do c &list a b c e g &if [extract %b% [value layer%a%]] gt 0 &then &do &select %c% &when c; &do &if %a% lt 10 &then &s line %line%'%'%a%'c %'%a%'d ' &else &s line %line%'%'%a%'c %'%a%'d ' &s line%n% '%'%a%'c checkbox '%a%'c' &s n [calc %n% + 1] &s line%n% '%'%a%'d checkbox '%a%'d' &s n [calc %n% + 1] &s %a%c .FALSE. &s %a%d .FALSE. &end /* when &when e; &do &if %a% lt 10 &then &s line %line%'%'%a%'e %'%a%'f ' &else &s line %line%'%'%a%'e %'%a%'f ' &s line%n% '%'%a%'e checkbox '%a%'e' &s n [calc %n% + 1] &s line%n% '%'%a%'f checkbox '%a%'f' &s n [calc %n% + 1] &s %a%e .FALSE. &s %a%f .FALSE. &end /* when &otherwise; &do &if %a% lt 10 &then &s line %line%'%'%a%%c%' ' &else &s line %line%'%'%a%%c%' ' &s line%n% '%'%a%%c%' checkbox '%a%%c% &s %a%%c% .FALSE. &s n [calc %n% + 1] &end /* otherwise &end /* select &s b [calc %b% + 1] &end /* then do &else &do &s line %line%' ' &if %c% eq c or %c% eq e &then &s line %line%' ' &s b [calc %b% + 1] &end /* else do &end /* do list &s line %line%'%'%a%'h' &s line%n% '%'%a%'h checkbox '%a%'h' &s n [calc %n% + 1] &s x [write %menu% [subst %line% '''' ' ']] &end /* do to by &s x [write %menu% ' ---------------- ------ ------ ------ ------ ~ ------ ------ ------ ------'] &s x [write %menu% ' '] &s x [write %menu% ' Specify width of DXF-TEXT item (default is 40)'] &s x [write %menu% ' %dxftext'] &s x [write %menu% ' '] &s x [write %menu% ' Specify width of DXF-ATTRIBUTE item (default is 16)'] &s x [write %menu% ' %dxfattrib'] &s x [write %menu% ' '] &s x [write %menu% ' Enter name of cover to convert DXF file to'] &s x [write %menu% ' %cover'] &s x [write %menu% ' '] &s x [write %menu% ' After converting the DXF file to a cover, line and ~ point attributes will be'] &s x [write %menu% ' created and joined to the DXF .ACODE and .XCODE info ~ files respectively.'] &s x [write %menu% ' '] &s x [write %menu% ' %proceed'] /* Write the action of each widget in the menu &s x [write %menu% '%0 checkbox 0'] &do a = 1 &to [calc %n% - 1] &by 1 &s x [write %menu% [value line%a%]] &end /* do to by &s x [write %menu% ~ '%dxftext slider dxftext 40 typein yes step 1 integer 0 255'] &s x [write %menu% ~ '%dxfattrib slider dxfattrib 40 typein yes step 1 integer 0 255'] &s x [write %menu% '%cover input cover 8 required return ~'] &s x [write %menu% ~ ' ''&s .gsc$msg Cover [upcase %cover%] already exists; ~'] &s x [write %menu% ~ ' &if [exists %cover% -cover] &then; &thread &create msg &modal &menu msg ~'] &s x [write %menu% ~ ' &pos ¢er &thread dxfai &stripe ''''Message!'''' ~'] &s x [write %menu% ~ ' &pinaction ''''&s cover'''' '' character'] &s x [write %menu% '%proceed button ''Proceed to Convert'' &return'] /* Write forminit action of menu &s x [write %menu% '%forminit &s cover; &s dxftext 40; &s dxfattrib 16'] &s x [close %menu%] &end /* else do /* Display menu for users to choose which DXF layers and entities to convert &menu [entryname %file% -noext].menu &pos &below &thread wimp &pinaction ~ '&return' &stripe [quote Convert [upcase [entryname %file%]] to a Cover] /* Begin converting DXF file to a cover &mess &off &all DXFARC %file% %cover% %dxftext% %dxfattrib% &if %0% &then &do $REST ALL &mess &on Y &end /* then do &else &do &do a = 1 &to %layers% &by 1 &if [value %a%h] &then [extract 1 [value layer%a%]] ALL &else &do &s line [extract 1 [value layer%a%]] &do b &list a b c d e f g &if [variable %a%%b%] &then &do &if [value %a%%b%] &then &do &select %b% &when a &s line %line% ARCS &when b &s line %line% POINTS &when c &s line %line% TEXTPOINT &when d &s line %line% TEXTANNO &when e &s line %line% ATPOINT &when f &s line %line% ATANNO &when g &s line %line% INSERT &end /* select &end /* then do &end /* then do &end /* do list &if ^ [null [extract 2 %line%]] &then [value line] &end /* else do &end /* do to by END &mess &on Y &end /* else do /* Build line and point attributes and join ACODE and XCODE to AAT and PAT &if [exists %cover% -cover] &then &do &describe %cover% &if %dsc$arcs% gt 0 &then &do BUILD %cover% LINE JOINITEM %cover%.AAT %cover%.ACODE %cover%.AAT %cover%-ID %cover%-ID &end /* then do &if %dsc$points% gt 0 &then &do BUILD %cover% POINT JOINITEM %cover%.PAT %cover%.XCODE %cover%.PAT %cover%-ID %cover%-ID &end /* then do &end /* then do /* Set .gsc$cov variable &if [exists %cover% -cover] &then &s .gsc$cov [joinfile [show workspace] [locase %cover%] -sub] &return &routine ERROR &severity &error &ignore &s x [close -all] &return; &return &warning Error in AML