Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

VBA Attribute edit in AutoCAD

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

Suggested Solutions

I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

807 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