Solved

Macros in AutoCad...

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Our company has proprietary drawing files that we do not give to our customers for final documentation. Our customers now require that we give them these drawings. They understand that they are proprietary and do not require them to be in AutoCAD bu…
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!…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now