Solved

Macros in AutoCad...

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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printer problem? 3 380
arcMap:  DBA number field types show 0 2 224
dwg drawings 3 108
Game Asset Design and Performance. 7 204
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!…
The following article will describe how to add/edit a dimension style through AutoCAD VBA. AutoCAD VBA has its quirks and when it comes to dimensions and controlling how they look through VBA.  This is where AutoCAD can be vividly confusing. The…
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…
Suggested Courses

752 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