WPMidas00146 June2011
GuidebyMilesNicholson
ScriptWriting
AllAutoCADElectricalUsers
Ascriptdoesonethingandonethingonly:[Link]
AutoCADthatshowsupontheCommand:linepromptcanbeputintoascriptfile.
AutoCADandthereforeAutoCADElectricalcanrunthemajorityofitscommandsfromtheCommandlinewithout
[Link]
whatisknownasascriptonanindividualdrawing,selecteddrawingsoranentireproject.
AnexamplemaybesimplythatyouwanttoperformaZoomExtents,[Link]
AutoCADcommandscouldtakedaysonseveralhundreddrawings!
Amajorpartofwritingscriptsistounderstandhowacommandoperatesandwhatkeyinputsmovethe
[Link](forzoom)atthecommandpromptwillgiveseveraloptionssuchasW
(window),E(extents),D(dynamic)etc
MostAutoCADandAutoCADElectricalcommandshavedialogueswhichbasicallymeanapopupboxappears
whenthecommandisinitiatedyetthemajorityofcommandscanhavetheirpopupdialoguesturnedoff.
AutoCADitselfhasvariablesthatturnoffthemajorityoffileandcommanddialogues
TypeFILEDIAatthecommandpromptandsetto0toturnofffiledialogueboxes(Open&Savecmds)
o Type1toreenable
TypeCMDDIAatthecommandpromptandsetto0toturnoffcommanddialogueboxes
o Type1toreenable
Furthermore,dependingonAutoCADversion,acommandmayhaveitsdialogueboxturnedoffbytypinga
oran_(dependingoncommandandversionofAutoCAD)[Link]=
PURGE=_PURGE.
BecauseAutoCADElectricalisprojectbasedconsistingofmultipledrawingswithinaproject,theadvantageof
beingabletorunscriptshasafargreaterbenefitthannormalgenericAutoCADandcanautomateyourdesign
processfarinexcessofotherCADrequirements/departmentssuchasyourmechanicalcounterparts.
Letssayinthisexampleweneedtodothefollowing:
MakeLayer0current
PerformZoomExtents
PerformanAudittofixanypotentialerrors
PerformaPurgeBlocks
TrytypingeachcommandattheCommand:linetogetusedtohowtodefinecorrectly
ThenormalcommandforlayersisLAYER
[Link].
LAYER
YouarethenshownaseriesofoptionsontheCommand:[Link],you
haveasanexampleM=Make,S=Set,F=FreezeetcsothenextoptionwouldbeSET
GivingthecommandoptionofEnterlayernametomakecurrent.Entering0willmake0thecurrentlayer
Andfinallytofinishthecommandoffwenowneedtoenteranadditionalcarriagereturn
Sotheentirecommandis:
LAYER
S
0
WecannowmoveontoZoomExtents
Z
E
HowevertheZoomcommandisoneofonlyafewcommandswithinAutoCADthatdonotfollownormal
[Link]
[Link]
ZOOM
E
...andthenAudit
AUDIT
Y
...andthenPurge
PURGE
B
*
N
Puttingallthecommandstogetherwenowhaveascriptof:
LAYER
S
0
ZOOM
E
AUDIT
Y
PURGE
B
*
N
Runningthescriptonyourproject([Link])
FromtheProjectribbontab,select Utilities
SelectRuncommandscriptfile
Select
RightclickonanyexistingscriptandselectCopy
RightclickandPastethecopyintothesamedirectorylocation
[Link]
RightclickoverthefiletoOpeninNotepad
Removeanyexistingtextandreplacewiththescriptdefinedabove(therepresentsacarriagereturnONLY)
SelectFile>Save
CloseNotepad
Highlightthescriptfromtheavailableonesandselect
Select
SelectProject
Select
Select
Select
Obviouslyascriptcanbefarmorecomplexthantheabovewhereyoumayevencreatewiresandinsertsymbols!
AutoCADElectricalalsohasafullAPI(advancedprogramminginterface)whichisdefinedintheElectricalHelp
Happyscriptwriting