+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Forum Newbie
    Using
    AutoCAD 2012
    Join Date
    Apr 2012
    Posts
    5

    Default Using Excel To Change Text in CAD drawing

    Registered forum members do not see this ad.

    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.

  2. #2
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,986

    Default

    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.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  3. #3
    Forum Newbie
    Using
    AutoCAD 2012
    Join Date
    Apr 2012
    Posts
    5

    Default Thanks Mircea,

    Thanks Mircea,

    I've downloaded the VBA extension for Acad 2012. and started using it.
    Will revert with the results.
    Thank you so much..!

  4. #4
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,986

    Default

    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.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  5. #5
    Forum Newbie
    Using
    AutoCAD 2012
    Join Date
    Apr 2012
    Posts
    5

    Default

    Quote Originally Posted by MSasu View Post
    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

  6. #6
    Forum Deity MSasu's Avatar
    Discipline
    Construction
    MSasu's Discipline Details
    Occupation
    engineer
    Discipline
    Construction
    Details
    AutoLISP programmer
    Using
    AutoCAD 2013
    Join Date
    Mar 2009
    Location
    Brasov, Romania
    Posts
    2,986

    Default

    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.
    Regards,
    Mircea

    AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3

  7. #7
    Forum Newbie
    Using
    AutoCAD 2012
    Join Date
    Apr 2012
    Posts
    5

    Default

    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.

  8. #8
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,780

    Default

    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.
    A man who never made mistakes never made anything

  9. #9
    Super Moderator SLW210's Avatar
    Computer Details
    SLW210's Computer Details
    Operating System:
    Windows 7 PRO
    Computer:
    IBM Lenovo
    Motherboard:
    ACPI x86
    CPU:
    Pentium(R) Dual-Core CPU E5500 @ 2.80GHz
    RAM:
    4 GB RAM
    Graphics:
    Nvidia Quadro 600 1GB
    Primary Storage:
    300 GB
    Secondary Storage:
    650GB
    Monitor:
    ThinkVision 22"
    Discipline
    Multi-disciplinary
    SLW210's Discipline Details
    Occupation
    Design Draftsman
    Discipline
    Multi-disciplinary
    Details
    Mostly do drafting related to manufacturing. From doing site layouts with proposed updates, additions and renovations to be budgeted and submitted for bid, to updating and changing existing drawings to reflect maintenance and repair/revision work done on site.
    Using
    AutoCAD 2011
    Join Date
    May 2007
    Location
    South Florida, USA
    Posts
    9,092

    Default

    Registered forum members do not see this ad.

    samuraxt,

    Please read the CODE POSTING GUIDELINES!
    “A narrow mind and a fat head invariably come on the same person” Zig Zigler



Similar Threads

  1. Using Excel To Change Text in CAD drawing
    By sublim21 in forum AutoCAD Beginners' Area
    Replies: 17
    Last Post: 28th Apr 2012, 07:50 am
  2. Fuzzy text in excel link. How to sharpen the text?
    By numberOCD in forum AutoCAD General
    Replies: 0
    Last Post: 20th Apr 2012, 07:58 pm
  3. How to Change Data from excel became plot in autocad automatically
    By zhamank in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 5
    Last Post: 23rd Mar 2012, 06:39 pm
  4. Text Color Change Makes Text Move??
    By geocad in forum AutoCAD General
    Replies: 2
    Last Post: 29th Dec 2011, 09:50 pm
  5. Change multiple Dimensions measured text into normal text?
    By apsonwane in forum AutoLISP, Visual LISP & DCL
    Replies: 12
    Last Post: 1st Jun 2011, 09:31 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts