samuraxt Posted April 28, 2012 Posted April 28, 2012 Hi, I have a question about if it is possible to set a block's dimensions to read a table's cell value. Say a rectangle has dimensions x wide by y tall and a table has the x and y values given in cells a1 and b1 linked from an excel spreadsheet. I would like to link it like this because i have an excel file that will update and then output to AutoCAD. Is this possible and if so how? I am planning on using VBA is this the best way to accomplish this? I am using AutoCAD 2012 if that helps. Quote
MSasu Posted April 28, 2012 Posted April 28, 2012 The support for VBA was discontinued since AutoCAD 2010; however you can download and install VBA extension for all versions up to 2013. This is intended for existing VBA custom tools. For new tools is better to look for AutoLISP or .Net. Regarding access to Excel from an AutoCAD based tool the answer is yes, it is possible. You can find a lot of examples on the Forum. Quote
samuraxt Posted April 30, 2012 Author Posted April 30, 2012 Thanks Mircea, I've downloaded the VBA extension for Acad 2012. and started using it. Will revert with the results. Thank you so much..! Quote
MSasu Posted April 30, 2012 Posted April 30, 2012 The compatibility with VBA is maintained by Autodesk to allow users that have such tools developed in the past to still use them. But is to expect that will be dropped one day. If I were you, since is about to start to develop a new tool, I will look for a .Net approach. For sure this involve becoming familiar with a new language, but chances are to be forced to do this anyway later when VBA support will not be available anymore. Quote
samuraxt Posted April 30, 2012 Author Posted April 30, 2012 since is about to start to develop a new tool, I will look for a .Net approach. For sure this involve becoming familiar with a new language. Yes Mircea.. you are absolutely right. I too had that thought when i took up this project. Will try this out in .Net too and will revert with results or even queries . Below is the VBA program i landed at, since i am quite new to vba platform i'm unable to make the search string as a default constant text. Can you guide me in this pls. Thanks in advance. Sub ChangeText() Dim Selection As AcadSelectionSet Dim MText As AcadMText Dim SearchText As String Dim ReplaceText As String Dim FilterType(0) As Integer Dim FilterData(0) As Variant FilterType(0) = 0 FilterData(0) = "MTEXT" On Error Resume Next Set Selection = ThisDrawing.SelectionSets.Item("ssText") If Err Then Set Selection = ThisDrawing.SelectionSets.Add("ssText") Err.Clear Else Selection.Clear End If Selection.Select acSelectionSetAll, , , FilterType, FilterData SearchText = ThisDrawing.Utility.GetString(True, "Enter the search string: ") For Each MText In Selection If MText.TextString = SearchText Then ReplaceText = ThisDrawing.Utility.GetString(True, "Enter the replace string: ") MText.TextString = ReplaceText End If Next MText End Sub Quote
MSasu Posted April 30, 2012 Posted April 30, 2012 Sadly, I don’t have access to AutoCAD’s VBA editor right now and also have very limited experience on this mater – I suggest you to ask a moderator to move this thread .NET, ObjectARX & VBA area of the Forum where can gain attention from people with VBA/.Net knowledge . Also, please add code tags to your code excerpt. Quote
samuraxt Posted April 30, 2012 Author Posted April 30, 2012 Mircea.. Its fine. Just now i've done it of my own and it works great. Thank you so much . Will be reverting with a new project soon. Quote
BIGAL Posted May 1, 2012 Posted May 1, 2012 Search the net for the example "Shaft.dwg & shaft.xls" this is an old example of linking a dwg to excel change in excel dwg updates. Quote
SLW210 Posted May 1, 2012 Posted May 1, 2012 samuraxt, Please read the CODE POSTING GUIDELINES! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.