You are on page 1of 4

WPMidas00146 June2011

GuidebyMilesNicholson

ScriptWriting

AllAutoCADElectricalUsers

Ascriptdoesonethingandonethingonly:itmimicswhatistypedatthekeyboard.Anythingyouenterin
AutoCADthatshowsupontheCommand:linepromptcanbeputintoascriptfile.

AutoCADandthereforeAutoCADElectricalcanrunthemajorityofitscommandsfromtheCommandlinewithout
therequirementofpopupdialogueboxes.Thismeansthatmultiplecommandscanbegroupedtogetherin
whatisknownasascriptonanindividualdrawing,selecteddrawingsoranentireproject.
AnexamplemaybesimplythatyouwanttoperformaZoomExtents,aPurgeandanAudit.Thisinnormal
AutoCADcommandscouldtakedaysonseveralhundreddrawings!

Amajorpartofwritingscriptsistounderstandhowacommandoperatesandwhatkeyinputsmovethe
commandtothenextstage.EventypingZ(forzoom)atthecommandpromptwillgiveseveraloptionssuchasW
(window),E(extents),D(dynamic)etc
MostAutoCADandAutoCADElectricalcommandshavedialogueswhichbasicallymeanapopupboxappears
whenthecommandisinitiatedyetthemajorityofcommandscanhavetheirpopupdialoguesturnedoff.
AutoCADitselfhasvariablesthatturnoffthemajorityoffileandcommanddialogues

TypeFILEDIAatthecommandpromptandsetto0toturnofffiledialogueboxes(Open&Savecmds)
o Type1toreenable

TypeCMDDIAatthecommandpromptandsetto0toturnoffcommanddialogueboxes
o Type1toreenable

Furthermore,dependingonAutoCADversion,acommandmayhaveitsdialogueboxturnedoffbytypinga
oran_(dependingoncommandandversionofAutoCAD)proceedingthecommandnamee.gPURGE=
PURGE=_PURGE.

BecauseAutoCADElectricalisprojectbasedconsistingofmultipledrawingswithinaproject,theadvantageof
beingabletorunscriptshasafargreaterbenefitthannormalgenericAutoCADandcanautomateyourdesign
processfarinexcessofotherCADrequirements/departmentssuchasyourmechanicalcounterparts.

Letssayinthisexampleweneedtodothefollowing:

MakeLayer0current
PerformZoomExtents
PerformanAudittofixanypotentialerrors
PerformaPurgeBlocks

TrytypingeachcommandattheCommand:linetogetusedtohowtodefinecorrectly

ThenormalcommandforlayersisLAYER
Howeverifwenowproceedthecommandwitha.Thesignifiesacarriagereturn.

LAYER

YouarethenshownaseriesofoptionsontheCommand:line.Lookingatthecapitallettersofeachoption,you
haveasanexampleM=Make,S=Set,F=FreezeetcsothenextoptionwouldbeSET

GivingthecommandoptionofEnterlayernametomakecurrent.Entering0willmake0thecurrentlayer

Andfinallytofinishthecommandoffwenowneedtoenteranadditionalcarriagereturn

Sotheentirecommandis:

LAYER
S
0

WecannowmoveontoZoomExtents

Z
E

HowevertheZoomcommandisoneofonlyafewcommandswithinAutoCADthatdonotfollownormal
convention.YoucantypeZatthecommandpromptbutyoucanttypeZwithinascriptasitwillhaltthescript
statingthatZisanunrecognisedcommand.InthisinstancewehavetotypethefullcommandZOOM

ZOOM
E

...andthenAudit

AUDIT
Y

...andthenPurge

PURGE
B
*
N

Puttingallthecommandstogetherwenowhaveascriptof:

LAYER
S
0

ZOOM
E
AUDIT
Y
PURGE
B
*
N

Runningthescriptonyourproject(N.B.Youmustbeinoneofyourcurrentactiveprojectsdrawings)

FromtheProjectribbontab,select Utilities

SelectRuncommandscriptfile

Select

RightclickonanyexistingscriptandselectCopy

RightclickandPastethecopyintothesamedirectorylocation

RightclickoverthecopiedfileandRenametoadifferentnamee.g.CLEANUP

RightclickoverthefiletoOpeninNotepad

Removeanyexistingtextandreplacewiththescriptdefinedabove(therepresentsacarriagereturnONLY)

SelectFile>Save

CloseNotepad

Highlightthescriptfromtheavailableonesandselect

Select

SelectProject

Select

Select

Select

Obviouslyascriptcanbefarmorecomplexthantheabovewhereyoumayevencreatewiresandinsertsymbols!
AutoCADElectricalalsohasafullAPI(advancedprogramminginterface)whichisdefinedintheElectricalHelp

Happyscriptwriting

You might also like