VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Embed AcCtrl control on a VBA userform & select objects (as standalone)

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
1756 Views, 2 Replies

Embed AcCtrl control on a VBA userform & select objects (as standalone)

Hi, 

 

First of all, I am not an expert in VBA. But have learnt a few methods through on the job experience.

 

Here is what I exactly want to do:

  1. Build a VBA Userform.
  2. Add AcCtrl control on it.
  3. Add a ListBox Control on it.
  4. Open a drawing and display on it.
  5. Allow user to select an object. (Filter will be applied on type of object. For present case, say “TEXT” object types)
  6. Then extract a specific attribute from the object and display in the listbox control. (For present case, consider attribute to be text contents of selected “TEXT” object.

When I attempted to build the above code, I succeeded upto point 4 and also I am able to draw basic objects using "SendCommand" method.

(All these without opening AutoCAD application)

 

But when I try to build selection sets, it dispays error saying - "AutoCAD main window is invisible".

 

I am planning to run this VBA on MS Excel and I want to display the table of attributes (listbox) adjacent to drawing window. Hence I was trying to use this AcCtrl method for selection.

 

If I use AutoCAD main window for selection, I will have to keep switching (activating) the corresponding window for every selection.

 

Can anyone let me know if it is possible to use AcCtrl to select object as explained above? If so, please guide me how to go about...

Tags (1)
2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: Anonymous

Using AcCtrl (TrueView as ActivX control) has the same functionality limitation as TrueView: it is meant for viewing and printing only. It does not provide full API to access drawing data and API for use interaction, such as selecting entities in AutoCAD editor (as you know that TrueView is not full AutoCAD).

 

So, no you cannot achieve what you want to do (to select particular entities, be it asking user to pick, or using code to select) and extract data from drawing/entities.

 

You need to use full AutoCAD. Further, if you use AutoCAD, it would be better to do VBA in AutoCAD than from external app (such as from Excel's VBA).

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3
Anonymous
in reply to: norman.yuan

Thanks for your quick reply.

 

I too considered initially that AcCtrl is only for viewing and printing.

 

But when I tried to use "sendcommand" and drew a circle, it got perfectly executed without AutoCAD main window open. Hence I thought that it must be having all other features too. If it had same limitations as that of TrueView, then how come it executed a "sendcommand" instruction? This was my doubt which led to the assumption that it must allow object selection too.

 

Now that you have made it clear that using AcCtrl, object selection cannot be made, I shall either use VBA in AutoCAD itself or think of switching the window on each operation.

 

Thanks again...

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost