Solved

VBA Select object programmatically in Autocad

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

756 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