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
Solved

VBA Select object programmatically in Autocad

Posted on 2011-02-27
3
2,566 Views
Last Modified: 2013-12-20
Hello here,

I wonder if it is possible to select an object programmatically, that is to say without clicking on it. This way it would be possible to modify a drawing file without any action of the user on autocad.

I was thinking about a vba equivalent of the rectangle selecting objects by using two points.

Thank you.
0
Comment
Question by:MisterM86
  • 2
3 Comments
 
LVL 10

Expert Comment

by:borgunit
ID: 34996268
Yes it is very possible. What are you trying to do exactly?
0
 
LVL 10

Assisted Solution

by:borgunit
borgunit earned 250 total points
ID: 34996290
Maybe I should have read closer. Sorry. Here is an example of creating a rectangle.

'Create rectangle
Public Sub MakeRectangle()
Dim vVertices(0 To 9) As Double
Dim acPline as AcadEntity
   
' Define the 2D polyline vVertices
vVertices(0) = 0:       vVertices(1) = 0
vVertices(2) = 84#:     vVertices(3) = 0
vVertices(4) = 84#:     vVertices(5) = 20#
vVertices(6) = 0:       vVertices(7) = 20#
vVertices(8) = 0:       vVertices(9) = 0

Set acPline = Thisdrawing.Modelspace.AddLightWeightPolyline(vVertices)
End sub
0
 
LVL 12

Accepted Solution

by:
silverkorn earned 250 total points
ID: 34996900
what kind of objects are you trying to select?

did you look at the SelectionSets function?
ThisDrawing.SelectionSets.Add.SelectByPolygon

the problem is if the coordinates change where your objects are located this will not work for all drawings. It would be much easier if you know exactly what layers the objets are located on or other defining criteria.

Also as a side note, keep in mind that the newer versions of AutoCAD will not support VBA, they are now moving to using the .NET languages, more can be found here:
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=770215
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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
VB6 - Convert HH:MM into Decimal 8 62
Help me. 3 60
Error with a code discussed on this page 5 29
VBA to find and replace multiline text from VBA modules 8 63
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

809 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