Solved

VBA Attribute edit in AutoCAD

Posted on 2011-02-15
5
1,418 Views
Last Modified: 2012-05-11
I have a script to run global Attribute edit

Command: -ATTEDIT
Edit attributes one at a time? [Yes/No] <Y>: N
Edit only attributes visible on screen? [Yes/No] <Y>: Y
Enter block name specification <*>: Tree
Enter attribute tag specification <*>: PlantID
Enter attribute value specification <*>:

<Select Attributes>
1 attributes selected.
Enter string to change: .
Enter new string:

this runs off a icon ^c^c^c_-attedit;n;y;tree;plantid;;\;;\;

I am trying to run it from a VBA form, activated by the icon.

Firstly i need to be able to pause the routine for the user to manually select the desired blocks.
Secondly I would like it to replace the whole string to change regardless of what is entered there, if that is possible.
The form would also have a text box to enter the new string if you know it (as a code), and a browse button if you don't.
Clicking the browse button would open a second form that is connected to a database (Plant.mdb) which has plant names and codes that you can select. on selection it fills out the text box for you.

 

I created a single form and routine, but only got to the point of select attribute. I am new to this and it was a struggle to even get the routine to run at all, i am at a loss.

 

Any help is much appreciated
0
Comment
Question by:GegH
  • 3
  • 2
5 Comments
 
LVL 12

Expert Comment

by:silverkorn
ID: 34896369
It might be helpful if you can post some of the code that you are using for others to look at.

also keep in mind that any future iterations of AutoCAD will not use Visual Basic as a supported programming language, they started back in 2009 to migrate to using .NET languages. In your case moving to VB.NET now would be very beneficial, depending on what version of AutoCAD you are writing the macro for.

Back to your original question, am I understanding you correctly that you are trying to create a routine that the user will select a Tree block in the drawing to change its attribute to a specific tree/plant type that is found within a database file?
0
 

Author Comment

by:GegH
ID: 34900441
Silverkorn,
I heard that they were fazing out VBA. I also heard that C++ was the way to go as well. I am afraid i don't know any of them. What are the differences?

The attached code is not very much at all, and not very well formatted i'm sure. as you can see i haven't got very far and It took me for ever to just get it to mimick the script i already had, even then it stops when autocad requires Object selection. I have been trying to pick up phrases from the internet,

it is surprising how little there is out there about what the codes mean. There is plenty of code that does all sorts, just nothing that explains what it all means, so i don't know whether i am doing VBA, VB.net, C++ or lsp.

I am very keen to learn.
Private Sub cmdEnter_Click()

    ThisDrawing.SendCommand ("_-ATTEDIT") & (" ") & ("N") & (" ") & ("Y") & (" ") & ("Tree") & vbCr & ("PlantID") & vbCr & vbCr & acSelectionSetCrossingPolygon & vbCr & vbCr

    End
End Sub

Open in new window

0
 
LVL 12

Expert Comment

by:silverkorn
ID: 34900514
For more information about AutoCAD .NET programming:
http://docs.autodesk.com/ACD/2010/ENU/AutoCAD%20.NET%20Developer's%20Guide/index.html

Unfortunately my understanding of AutoCAD programming is very limited but here are two great sources of great information:

AUGI (Autodesk User Group International)
http://forums.augi.com/forumdisplay.php?f=88

TheSwamp.org
http://www.theswamp.org/index.php?
0
 

Author Comment

by:GegH
ID: 34901352
Thanks for that, i guess i'd need Microsoft Visual Studio (Express??) to write VB.net?
0
 
LVL 12

Accepted Solution

by:
silverkorn earned 500 total points
ID: 34901406
Yes, your better off using 2008 as AutoCAD uses NET 3.5 and not 4.0 (which is standard in 2010)

Visual Studio 2008 Express:
http://www.microsoft.com/visualstudio/en-us/products/2008-editions/express

About using AutoCAD 2011 and Visual Studio 2010:
http://forums.augi.com/showthread.php?t=120155

oh and to answer one of your previous questions, I'm not sure what all the differences between VBA and VB.NET but it appears that the calls and variables are some of the key changes.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
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…

815 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

7 Experts available now in Live!

Get 1:1 Help Now