Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VBA Attribute edit in AutoCAD

Posted on 2011-02-15
5
Medium Priority
?
1,515 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
[X]
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
  • 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 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

670 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