Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Macros in AutoCad...

Posted on 2004-09-18
2
Medium Priority
?
2,424 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 500 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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!…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

705 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