viagra torino prescrizione viagra sildenafil 100mg preis kamagra verkoop tadalafil effetti collaterali acquistare cialis generico cialis eds apotheke cialis berlin pfizer viagra preis viagra preise schweiz comprare cialis günstiger viagra cialis apotheke holland levitra per nachnahme viagra aus indien vendita cialis generico in italia viagra rezeptfrei preis alternativ viagra koop cialis cialis preise schweiz viagra rezeptfrei rechnung cialis sublinguale cialis da banco levitra filmtabletten viagra senza prescrizione medica levitra ricetta cialis apotheek viagra rezept bekommen viagra senza ricetta medica cialis internetapotheke cialis legal kaufen viagra ohne rezept kaufen original viagra rezeptfrei original levitra rezeptfrei koop levitra pille viagra generika potenzmittel viagra roma acquistare viagra in svizzera viagra deutschland kaufen cialis 5 mg preis preisvergleich viagra 50 mg cialis versand aus deutschland durata levitra viagra preis apotheke viagra apothekenpflichtig cialis rezeptfrei in holland costo cialis farmacia viagra nachnahme levitra rezeptfrei bestellen levitra alternative viagra alternative cialis preis viagra serve la ricetta cialis 5mg kaufen cialis efeitos secundarios prezzo farmacia cialis viagra kaufen ohne rezept forum viagra original kaufen cialis generico italia cialis preis frankreich levitra online kaufen holland viagra rezeptfrei erectie stoornis naturliche potenzmittel viagra online kaufen de viagra 100 mg prezzo versand viagra erektile dysfunktion opinioni levitra cialis 5 mg generico viagra kaufen in der apotheke cialis in österreich kaufen generika sildenafil viagra apotheke viagra tschechien viagra ersatz viagra ersatzmittel cialis vendita in farmacia il viagra alternativa viagra naturale viagra preisvergleich filmtabletten cialis pille viagra viagra ohne rezept holland acquistare cialis viagra im ausland kaufen viagra generika erfahrungsberichte cialis generico opinioni acquistare viagra online cialis da 10 mg mannen pil viagra kaufen angebote levitra generika erfahrungen cialis filmtabletten viagra in holland uso levitra viagra sicher kaufen günstig cialis costo cialis generico compra viagra online erectiepillen cialis donna cialis per nachnahme generische cialis levitra mit rezept viagra 50mg rezeptfrei erektionsstorung viagra zu kaufen impotentie cialis preis österreich eu viagra viagra per le donne cialis kaufen rezeptfrei viagra senza ricetta in farmacia viagra effetti donne viagra kaufen erfahrungen cialis dosaggio vendo levitra viagra generika vergleich impotenza cure internetapotheke levitra comprare viagra svizzera cialis generico in farmacia cialis tabletten acquisto cialis in farmacia viagra senza ricetta versandapotheke cialis cialis sicher bestellen comprare cialis in farmacia online viagra und cialis kaufen acquistare cialis a san marino vendo cialis napoli viagra 25 mg kaufen potenzhilfe prezzo levitra 10 mg levitra naturale viagra venda livre levitra portugal viagra a basso costo levitra da 20 cialis generika bestellen cialis pagamento contrassegno viagra generika wirkung viagra rezeptfrei frankreich viagra günstig online viagra da 25 prezzo viagra farmacia cialis günstig viagra compro viagra rezeptfrei in deutschland viagra per nachnahme vendo cialis cialis cialis differenze cialis senza ricetta viagra costa cialis 5mg preis cialis donne comprare cialis online cialis generico 5mg prezzo viagra viagra al naturale viagra vendita italia viagra x donne vendita viagra generico comprare viagra italia viagra im internet bestellen strafbar cialis 20 mg generico viagra alternativo tabletten cialis viagra sublinguale viagra schweiz kaufen potenzmittel rezeptfrei viagra per nachnahme kaufen viagra kosten mit rezept viagra in deutschland cialis aus indien tadalafil costo viagra napoli ohne rezept bestellen viagra informazioni ricetta cialis levitra niederlande cialis generico contrassegno viagra generico europa viagra pillendienst prezzo tadalafil viagra generika rezeptfrei viagra in farmacia senza ricetta acquisto viagra farmacia cialis rezeptfrei niederlande viagra pillenmaster cialis billig alternatief viagra generika levitra cialis soft kaufen cialis costo levitra kaufen ohne rezept tadalafil preis günstig viagra kaufen cialis preisliste acquistare viagra farmacia impotencia comprare cialis in contrassegno acquisto viagra in svizzera generic sildenafil viagra in holland kaufen viagra kaufen apotheke forum cialis generico tadalafil generico italia viagra efeitos levitra 20mg filmtabletten costo tadalafil levitra billig kaufen sildenafil preise viagra schweiz prezzo viagra italia generico do viagra cialis im ausland kaufen tadalafil prezzo cialis online vendita viagra apotheke holland acquisto viagra senza ricetta levitra ricetta medica prezzi cialis costo cialis in francia acquistare viagra in italia cialis 10mg preis levitra preiswert viagra comprare viagra original ohne rezept levitra verkauf levitra 20 mg preisvergleich potenzpillen cialis te koop cialis kaufen in deutschland cialis naturale in farmacia viagra günstiger viagra controindicazioni cialis preis deutschland posologia cialis online apotheke viagra zonder recept costo cialis 20 mg viagra soft generico viagra preise deutschland tadalafil nachnahme cialis dosaggio consigliato koop kamagra viagra kaufen rezeptfrei viagra verschreibungspflichtig viagra italia comprare viagra in svizzera prezzi levitra viagra europa viagra kaufen privat levitra funziona cialis kaufen schweiz viagra kaufen in der schweiz viagra alle donne viagra generika nebenwirkung viagra rezeptfrei länder viagra rezept online viagra nur auf rezept cialis dove comprarlo rezeptfrei levitra viagra preis viagra kaufen in berlin viagra aus holland viagra generika 100 mg viagra apotheke rezeptfrei tadalafil soft levitra generika kaufen cialis vendita generic tadalafil generika farmaco cialis 20 mg viagra acquisto online viagra 100 mg preisvergleich sildenafil rezeptfrei viagra im internet cialis versandapotheke kamagra te koop levitra versand viagra naturale in erboristeria tadalafil online bestellen comprare viagra senza carta di credito levitra rezeptfrei schweiz vardenafil bestellen viagra online versand cialis fa bene cialis kaufen holland online apotheke cialis viagra pills cialis generico effetti collaterali sildenafil ohne rezept levitra ohne rezept cialis pagamento paypal viagra kopen viagra rezeptfrei wo apothekenpreis viagra viagra kauf viagra günstig rezeptfrei viagra pagamento alla consegna viagra online kaufen erfahrungen disfunzione erettile rimedi viagra generico opinioni levitra prezzi viagra generika test viagra ricetta medica levitra vardenafil generika viagra prijs viagra generika wikipedia cialis controindicazioni cialis kaufen billig viagra kaufen usa preis viagra preisvergleich medikament cialis potentie pil viagra verkauf levitra te koop tadalafil preisvergleich cialis serve la ricetta acquisto cialis generico viagra niederlande levitra online apotheke erectie lengte posologia viagra costo cialis viagra rezeptfrei preisvergleich levitra verkoop viagra generika deutschland cialis torrino cialis italia viagra ohne rezept apotheke acquisto viagra in italia cialis kaufen deutschland cialis vendita italia prezzi viagra viagra farmacie cialis pille comprare levitra tadalafil 20mg kaufen cialis bestellen forum levitra kopen viagra usa kaufen viagra kaufen in thailand cialis seriös kaufen erectieplein cialis professional cialis in farmacia senza ricetta alternative cialis levitra günstig

Writing AutoCAD Scripts With Excel

kick it on CadKicks.com

A while back, I received some survey data in the form of a comma-delimited text file containing rows of Northings, Eastings, & elevations. I needed to take that information and place at every location in my drawing. At the time I only had plain AutoCAD (I wasn’t using Civil 3D yet). Being lazy, I wasn’t about to sit there and type the coordinates by hand. So I wrote a script! Here is how I did it.

I opened the text file in and did a Save-As so I wouldn’t ruin the original file. Then I re-arranged the data so it would make sense in a script. Remember, a script will run as if you were typing the commands in the command line.

Here is what I wanted my script to do: insert a specific block at each location (Northing-Easting). Simple enough.

The way the survey data was arranged was Northing first, then Easting, then elevation.

AutoCAD Fact: When you insert a block, AutoCAD wants the X coordinate before the Y coordinate.

Since the Northing is the Y coordinate and the Easting is the X coordinate, I needed to put the Easting column before the Northing column.

In I clicked on the “A” column, right-clicked, and selected “Insert” to insert a blank column in front of the Northings.

Then I rearranged the Northing-Easting data so it was in the correct order with the Eastings before the Northings. To do this I would select an entire column, right-click, and select Cut. Then select another blank column, right-click, and select Paste. Do this until you have the columns arranged with the Eastings before the Northings.

AutoCAD Fact: When the insertion command asks you where to place a block, you have to type coordinates with commas inbetween.

To get the commas in , add columns between the Northing, Easting, & elevation columns and paste commas in them. To do this, type a comma in the first cell, then select the entire column, right-click, and select Paste. This will put commas into each cell of the column.

In cell “1A” I started writing the block insertion macro – a series of commands seperated by spaces. Remember, in AutoCAD a space is the same as hitting Enter on the keyboard.

In this case I typed:

insert epp 

“Epp” is the name of the block that I have in my drawing. Note that I added a space after “epp” (because after the block name is typed you need to hit enter).

Then, just like the commas, copy & paste the macro into the rest of the cells of column A.

AutoCAD Fact: The INSERT command also requires you to specify a scale and rotation angle for each block inserted.

Thus in cells G, H, & I, I typed ~1, ~1, ~0 respectively.

If you want to specify a scale-factor other than 1 for your block, you could change this. For example, if you wanted the to be 20-scale, you would type ~20, ~20, ~0. The same goes for the rotation angle. If you wanted all your to be at a 45-degree angle, instead of typing ~0 in the last column, type ~45.

You may be wondering why I added a ~ in front of each number. Hang on. I’ll show you why later.

Copy all the cells…

Open Microsoft Notepad (or similar text editor) and paste the data into it…

You will notice tabbed spaces exist where the cell divisions were in . To remove those tabs, highlight one of the tabbed spaces, right-click, and select copy.

Then select Edit –> Replace…

In the “Find what” field, right-click and select Paste…

Leave the “Replace with” field as-is and click the “Replace All” button.

Notice the tilde (~) symbols on the right side of the text file? You will need to replace those with spaces. If we hadn’t put tildes in, there would be no way to put spaces between the numbers. To replace the tildes with spaces select Edit –> Replace…

In the “Find what” field, type ~. In the “Replace with” field simply hit the space bar once. Then click the “Replace All” button.

When saving the text file as a script, you need to set the “Save as type” to “All files” (see below) so that it will accept the .scr extension.

The script is now complete! Once you have saved it with a .scr extension, type SCRIPT on the command line in AutoCAD and browse to open your script file. It will run immediately inserting at every coordinate & elevation.

This method is much easier than typing each coordinate by hand and it saves you from making costly mistakes.

Bookmark and Share

28 Comments so far

  1. Sign up at Gravatar.com to add your picture. Jimmy Bergmark on September 19th, 2008

    One of the reasons I love to use Excel. ;-) I love these kind of tricks.
    Great posting.

  2. Sign up at Gravatar.com to add your picture. Josh Jones on September 19th, 2008

    Thanks Jimmy! It’s tricks like this that make “drafting” a lot more fun.

  3. Sign up at Gravatar.com to add your picture. CadKicks.com on September 19th, 2008

    Writing AutoCAD Scripts With Excel…

    You’ve been kicked (a good thing) – Trackback from CadKicks.com…

  4. Sign up at Gravatar.com to add your picture. sadiqnaick on October 28th, 2008

    i like this very much.

  5. Sign up at Gravatar.com to add your picture. Zena on October 31st, 2008

    I really like this except I don’t have a block already in my drawing like epp. I am looking to put in various survey control points into AutoCAD.
    Help?

  6. Sign up at Gravatar.com to add your picture. Zena on November 3rd, 2008

    I have added my own pt.dwg to be inserted, used your script directions and looks good. But I would like to see more on the points, like the names of the locations, so how would I add attribute definitions to all the points at the same time with another script? I have 276 points now in my drawing but no details.

  7. Sign up at Gravatar.com to add your picture. Josh Jones on November 3rd, 2008

    Good job Zena. I’m glad you figured it out to work with your own blocks. Is your pt.dwg block attributed?

    I haven’t tried it yet, but I imagine that if it was attributed you could modify the script to add the Northing, Easting, & Elevation in each block as attributes.

  8. Sign up at Gravatar.com to add your picture. sadiqnaick on November 4th, 2008

    write another script inserting a text at different points with all options like alignment .you have to write two scripts one for blocks and another for inserting the description of point.script does not work for the command which requires doalogue box.

  9. Sign up at Gravatar.com to add your picture. Josh Jones on November 4th, 2008

    If you have a block with attributes for Northing, Easting, & elevation, you could add that data to each block in the same script. Set ATTDIA to 0 and AutoCAD will prompt you for the attributes on the command line.

  10. Sign up at Gravatar.com to add your picture. sadiqnaick on November 5th, 2008

    while doing the survey instrument will read northing and easting and elevation but the location of target where it is placed has to be entered by surveyer.it can’t be applied to all surveyes.each area will have it’s own name like description which surveyor enters in the instrument.
    this data when appears on acad drawing the shape of a building can be cinstructed or a road can be marked or a drainage line can be identified.othewise it will be only points.
    so for every survey data can not be processed with only northing and esting.

  11. [...] my previous post on writing AutoCAD scripts with Excel for example. If you had a block that had Northing, Easting, & Elevation attributes in it, you [...]

  12. Sign up at Gravatar.com to add your picture. Naresh yadav on November 12th, 2008

    sir,
    I want to write owen script for find distance or length between two line on every 10m or any offset get data in Excel pl.guide me

  13. Sign up at Gravatar.com to add your picture. Josh Jones on November 18th, 2008

    Naresh,

    Can you clarify your request?

    -Josh

  14. Sign up at Gravatar.com to add your picture. sadiq on November 18th, 2008

    Mr/Ms zena
    each survey will have its own data.while doing survey itself we have to enter the description of a point,the northing and easting are location of a point where a target is place.in survey data a point ordinates are easting ang and northing.i.e., x,y ordinates.why do you want to place write the ordinates of a point at that point.instead you place a text at that point indicating that it is a boundary ,drainage ,building ,tree,pole etc.,
    that will serve the basic purpose of survey.
    scripts contain only one command in a line.you can place a block which contain attributes of north and east then you have to enter manually each and every one .because you can not give same value for all points.Mr jones can we do this.

  15. Sign up at Gravatar.com to add your picture. sadiq on November 18th, 2008

    i am sorry for the spellimg mistakes in my previous post.i am not good at typing.

  16. Sign up at Gravatar.com to add your picture. GLad on December 3rd, 2008

    I cannot get it to work for some reason. I followed your directions but I get this…
    Command: insert Enter BACKSPACE to interrupt script.
    Command: sb Unknown command "SB". Press F1 for help.

    sb is my block, any ideas?

  17. Sign up at Gravatar.com to add your picture. Josh Jones on December 3rd, 2008

    GLad,

    Can you copy/paste more of the command lines when this error occurs? This way I can get a better idea of what is causing the problem.

  18. Sign up at Gravatar.com to add your picture. Andrew on January 6th, 2009

    Instead of going through all the work to get comma’s in the file, why not save in Excel as a CSV? then open the CSV with notepad, it will seperate your values with comma’s! other than the fact that you don’t want comma’s between all the values… good thing to keep in mind though!:Cheers:Andrew

  19. Sign up at Gravatar.com to add your picture. Nick T on January 6th, 2009

    Instead of saving this a a script (.scr) file, just copy the data from the notepad and paste it into the command line.  Saves eve more time.

  20. Sign up at Gravatar.com to add your picture. Tim Black on January 6th, 2009

    The process of merging the columns of data in Excel can be made much easier by employing the concatenate function in Excel. Just write the function for one line of data in an empty cell, then highlight and drag the cell down to concatenate all lines of data. Highlight the result, copy, then Paste Values to complete the operation.

  21. Sign up at Gravatar.com to add your picture. Umesh S Rao on January 6th, 2009

    A neatly explained procedure for creating script using excel data.I have also created similar script files for creating specific graphs used by geologists

  22. Sign up at Gravatar.com to add your picture. qwazix on January 11th, 2009

    if you want to show text at various points you can use the -text command instead of the text command, which asks for the text on the command line

  23. Sign up at Gravatar.com to add your picture. Phoebe on April 13th, 2009

    This is the best explanation of ANYTHING to do with drafting I have ever read.  You should be writing the software manuals.

  24. Sign up at Gravatar.com to add your picture. Josh Jones on April 13th, 2009

    Thanks Phoebe.

  25. Sign up at Gravatar.com to add your picture. Naresh on April 15th, 2009

    Sir,I want to draw Cross section of Highway in Auto cad , I have Ground Level and Formation Level in Excel format. I have 7 KM data and want to Draw every 20m Cross section , so solve my problem .
    Regards
    Naresh
    CAD Engineer

  26. Sign up at Gravatar.com to add your picture. sagheerjani on May 18th, 2009

    this is great post and did u know about norting and easting i mean how to draw S39degreesE.

  27. Sign up at Gravatar.com to add your picture. Hugo Cruz on May 19th, 2009

    You are pretty good, you must be an excel god.. jajajaja.
    I need your help, I’m building a macro in Excel that gives me back a string that I copy and paste into command line in Autocad. is there any way to send directly that string to command line without having to copy and paste.
    Thanks in advance.

  28. Sign up at Gravatar.com to add your picture. ali on June 22nd, 2009

    hi every one around the world

    this is tremendous tips i like the above tips very much i m beginer unfortunataly our cheif and other senior surveyor do not give us any useful tips i personaly very fond of my job no one teach us any tipss thanks

Leave a reply

  • Viagra ordre
  • Cialis en ligne
  • Levitra en ligne
  • Propecia acheter
  • Viagra acheter
  • Acheter cialis
  • Ordre levitra
  • Ordre propecia
  • En ligne viagra
  • Vente cialis
  • Levitra bon marche
  • Propecia en ligne
  • Viagra online
  • Buy cialis
  • Order Levitra
  • Buy propecia
  • Buy viagra
  • Cheap cialis
  • Cheap Levitra
  • propecia online
  • Viagra prescription
  • Cialis online
  • Buy Levitra
  • Order propecia