Solved

VBA Select object programmatically in Autocad

Posted on 2011-02-27
3
2,438 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

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…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

13 Experts available now in Live!

Get 1:1 Help Now