Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm an old-time AutoCAD user, and I think I can help you with this. It really helps if you have access to AutoCAD. But I think there is a reference somewhere. Try my blog posts:</p> <p><a href="http://tomsthird.blogspot.com/2009/07/autocad-and-python-part-2.html" rel="nofollow">http://tomsthird.blogspot.com/2009/07/autocad-and-python-part-2.html</a></p> <p><a href="http://tomsthird.blogspot.com/2009/07/accessing-autocad-civil-3d-object-model.html" rel="nofollow">http://tomsthird.blogspot.com/2009/07/accessing-autocad-civil-3d-object-model.html</a></p> <p><a href="http://tomsthird.blogspot.com/2009/07/autocad-civil-3d-activex-object-model.html" rel="nofollow">http://tomsthird.blogspot.com/2009/07/autocad-civil-3d-activex-object-model.html</a></p> <p>In one of those posts, it looks like I have a link to a reference that's a chm file that comes with AutoCAD. There ought to be better.</p> <p>Here's how I did it in Visual LISP:</p> <pre><code> (VLAX-GET-PROPERTY (VLAX-INVOKE (VLAX-GET-PROPERTY (VLAX-GET-PROPERTY (VLAX-GET-ACAD-OBJECT) 'ACTIVEDOCUMENT) 'ACTIVESELECTIONSET ) 'ITEM 0 ) 'INSERTIONPOINT ) </code></pre> <p>I assume that in something like Python you would want to do this:</p> <pre><code>import win32com.client acad = win32com.client.Dispatch("AutoCAD.Application") doc = acad.ActiveDocument inspoint = doc.ActiveSelectionSet.Item.0.InsertionPoint </code></pre> <p>If this doesn't work for you, let me know, and we will work something out. I want to see you succeed, and I'd really appreciate it if you could share your finished code snippet here. As you can see from my blog posts, I, too, am interested in learning how to automate AutoCAD using Python. Maybe you can contact me and we can work together.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COThanks, Mr. Haws. I will check out your blog. Lately, i tried the DXF way to manipulate Autocad. But comtypes way will be much more efficient. I am new to Autocad automation. As a first step, my goal is to develop a program which is capable of converting a text table inside Autocad to Excel table. It is actually for my own use in my work. Not for commercial purposes. I always liked sharing my achievements. So if i succeed, it will be no problem for me to share what i did. It would be a pleasure for me to work with an experienced partner like you.
      singulars
    2. CO@Shansal, Tom Haws, I'm interested in AutoCAD Automation with Python too. I'm using Python scripts for automating tasks ffrom my electrical engineering work. I've made a small library (`comtypes` required). Feautures: simplifies work with coordinates (3D points), do efficient objects iteration (with casting to correct type), multitext format/unformat, optional Excel tables support (through `xlrd` and `tablib`), etc. [PyPI](http://pypi.python.org/pypi/pyautocad/), [examples](https://bitbucket.org/reclosedev/pyautocad/src/tip/examples) (Russian specific, sorry). But it has not documentation yet.
      singulars
    3. COShansal and reclosedev, this is very interesting. reclosedev, I see that you commented (answered) at http://stackoverflow.com/questions/9325162/win32com-connection-failure-to-autocad-via-python that comtypes is required. If you are successfully doing this, particularly if you are community-minded, I (and, I assume, Shansal) am very interested in talking further with you and beginning a library of AutoCAD Python code, and definitely going a little further with the solutions at my blog. I am a Python newbie. But I can help you guys with the nuances of AutoCAD.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload