Solved

Macros in AutoCad...

Posted on 2004-09-18
2
2,409 Views
Last Modified: 2012-06-27
I want to write a macro in cad to perform a simple task.  I have:

Sub Macro1()      '<-- this will be in autocad vba editor

 <Draw a line from point A(5,10) to B(5, 40)>   '<-- this is what I need.  

End Sub

This will be my first macro in cad (I am somewhat familiar with vb & vba).

Thanks.
0
Comment
Question by:Mike Eghtebas
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
norrin_radd earned 125 total points
ID: 12095511
this is one way to do it:

Sub drawline2()
    Dim aline As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double

    'Data
    startPoint(0) = 5#
    startPoint(1) = 10#
    startPoint(2) = 0#
   
    endPoint(0) = 5#
    endPoint(1) = 40#
    endPoint(2) = 0#
     
    'OLE Automation Object Calls
    Set aline = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
    aline.Update
End Sub

i copied that straight out of some code in the sample directory in your main acad directory, just changed it to your coords. the example there uses a form too. you should check out some of those examples they are an excellent start for vba for acad.

hope this helps

0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 12096238
Thank you Norrin.  I will give it a try and get back to you.

Mike
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ISP problem 4 519
AutoCad 2013 - How to identify new format files from old format (2007-2012) files 2 792
Why cannot we print a certain PDF file? 6 189
Simple 3D CAD 18 120
Following a number of instances of re-installing Solidworks I thought that it may be a  good idea to detail the procedure that I follow each time to ensure a good stable install. Backup: Backup your system.  It goes without saying that this i…
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question