Solved

Macros in AutoCad...

Posted on 2004-09-18
2
2,399 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
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 33

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AutoCad Plot Printing Cutting the print job off 7 1,136
Autocad DWG to PDF printing 5 1,060
Certificate Services 5 257
Solidworks 2010 download link? 5 1,007
If, like me, you find yourself repeatedly and tediously joining many segments (lines, arcs) in other people's drawings back into polylines that can be used more effectively in Computer Aided Machining and Laser Cutting, then this article is for you!…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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