Solved

VBA Attribute edit in AutoCAD

Posted on 2011-02-15
5
1,406 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

744 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

9 Experts available now in Live!

Get 1:1 Help Now