Link to home
Start Free TrialLog in
Avatar of GegH
GegHFlag for New Zealand

asked on

VBA Attribute edit in AutoCAD

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
Avatar of silverkorn
silverkorn
Flag of United States of America image

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?
Avatar of GegH

ASKER

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

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?
Avatar of GegH

ASKER

Thanks for that, i guess i'd need Microsoft Visual Studio (Express??) to write VB.net?
ASKER CERTIFIED SOLUTION
Avatar of silverkorn
silverkorn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial