Solved

VBA Select object programmatically in Autocad

Posted on 2011-02-27
3
2,692 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
[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
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month4 days, 2 hours left to enroll

630 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