Solved

VBA Select object programmatically in Autocad

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 51
Passing a Text Box name to a Sub 6 96
MsgBox 4 60
Export Data to Different .csv Files 26 105
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

770 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