
I found it by browsing the autocad installed files to see what number they kept using in their files.Īutocad also has an document method for calling tools just like you would type in Autocad. 18 will probably change for your version of Autocad. 18 but for the interface object that is critical (which took me forever to figure out!) Note that the. You can get the autocad application object by not including the. I don't know what they do but this is how you work with them color:=acad_handle.GetInterfaceObject("AutoCAD.AcCmColor.18"). In autocad there are things called interface objects. That last script has something special in it. Object.SetPattern(PatternType,PatternName)Ĭolor:=acad_handle.GetInterfaceObject("AutoCAD.AcCmColor.18")

Here is an example of looping through the current selection and doing something on the objects.Ĭode: Select all acad_handle:= ComObjActive("AutoCAD.Application.18") get a com object handle to and existing Autocad SessionĪcad_("Hatch") make new simple array now that it is sorted by key build list of objects with the key as their vertical location StringReplace, value%a_index%, value%a_index%, `r, AllĪctive_selection:=acad_ StringReplace, value%a_index%, value%a_index%, ", All StringReplace, value%a_index%, value%a_index%, `n, All Window := Acc_ObjectFromWindow(hwnd, -16) The Autocad window can be referenced like thisĪlso see below for a working script that writes a list of files from excel to autocad based on vertical height in Autocad (useful for large tabled drawings!) It requires the file Acc.ahk to be included in the script or AHK Lib folder.Ĭode: Select all msgbox Select a column of values to write to acad.ĬontrolGet, hwnd, hwnd,, Excel71, ahk_class XLMAIN This type of thing would work for creating any Autocad object (lines, blocks, viewports.) Text := "This is the text String for the mtext Object" See below for an example.Īcad_array:=acad_ However I did find that if you just find the type of array you need in the existing api you can copy it, write your new values and then use it anywhere that type is valid. I don't know what that is and I have tried writing one by creating an array object using array:= and ArrayObj := ComObjArray(VarType, Count1 ) to no avail. adauto.chm) anytime you need to read or write coordinates you need what they call a 3 element variant array of doubles. In the Autocad VBA help file (super hard to find online I found.

All are tested in Autocad Mechanical 2012.Īcad_handle:= ComObjActive("AutoCAD.Application.18") get a com object handle to an existing Autocad Session

Here is a list of tips and scripts that due useful things in Autocad.
