Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: How to connect data in Excel to Block inside Modelspace

  1. #1
    Member
    Join Date
    2006-03
    Posts
    14

    Question How to connect data in Excel to Block inside Modelspace

    hello. i have a problem here.i have an application where it can find block inside drwg,give the qty and place these report in the drwg.
    purpose :
    create an application to
    a)count block quantity
    b)extract block name and block graphical image
    c)open file(excel) which store the block description ("ID No","height","weight","symbol ","Qty","Block name")
    d)list all the block descriptions inside a table-like.
    can anyone show me how to pform this application?
    is it complicated?if it is,can u suggest anythg else?'

    1) can dbconnect connect the "BLOCK" inside drwg to the"EXTERNAL DATABASE ,like MSAccess/Excel for example?can sum1 show me how?code example,plz?
    2)i have a block type of plant named =" havea brasiliensis" which is stored in a plant file.
    is it possibble for me to extrct the block name with the image for the block altogether ?if possibble,then how?
    but..if it not possible, can sum1 here suggest to me in what way can i get the image represented the block ?because i need to putit inside the table altogether with the "Block Name"

    3)i have tried a code where the first time it executed successfully.But at the second time,it gave me an error .can sumone please tell me how to fix the error?i will attach below.hope to share with all of you out there.im really not an expert in this filed.im a very new beginner in this.really appreciate for any help.

    i really hope sumone out there can help me.please please..i really really need a help.i'm very begginer in this creating application using vb and autocad.please..any help/suggesstion would be great;thanks a lot.
    Attached Files Attached Files
    Last edited by i_len2884; 2006-04-04 at 05:08 PM. Reason: attach file.

  2. #2
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    482

    Default Re: How to connect data in Excel to Block inside Modelspace

    the first time you run the program the selectionset ONLYBLOCKS is not in the drawing the next time you run the program it is so you get a error

    Code:
    Set objnewss = objDoc.SelectionSets.Add("ONLYBLOCKS")
    change the code to
    Code:
    On Error Resume Next
    Set objnewss = objDoc.SelectionSets.Add("ONLYBLOCKS")
    Set objnewss = objDoc.SelectionSets("ONLYBLOCKS")
    On Error GoTo 0
    this way if the selectionset is in the drawing it will just do the next line and set objenewss to the selectionset

    you should add this code before you use the selectionset or any object in the old selectionset will stall be there
    Code:
    objnewss.Clear
    change
    Code:
     
    Dim objnewss As Object '''this line caused an error.why is it?.plz correct it.
    to this
    Code:
     
    Dim objnewss As AcadSelectionSet
    Last edited by jwanstaett; 2006-04-04 at 07:17 PM.
    Note:
    update to 2011
    I am using ADT 2007 08/06/2008

    PS. If you use any Code I post or Down Load Attachment I would like to know if it was helpful. So please post reply to this thread, on how you use the code or down load. Thank You

  3. #3
    Member
    Join Date
    2006-03
    Posts
    14

    Cool Re: How to connect data in Excel to Block inside Modelspace

    So thank you to u...i will try the codes and see what happen.i'll tell you the results tomorrow.Thanks a lot.

  4. #4
    Member
    Join Date
    2006-03
    Posts
    14

    Unhappy Re: How to connect data in Excel to Block inside Modelspace

    i already used it and it succeed but when i close the AutoCAD, i try to run the code again and it wont work...please help
    Last edited by i_len2884; 2006-04-12 at 03:58 AM.

  5. #5
    Member
    Join Date
    2006-03
    Posts
    14

    Unhappy Re: How to connect data in Excel to Block inside Modelspace

    Set objnewss = objDoc.SelectionSets.Add("ONLYBLOCKS")
    On Error Resume Next
    Set objnewss = objDoc.SelectionSets("ONLYBLOCKS")
    Set objnewss.clear
    On Error GoTo 0


    An error accured after "On Error Resume Next" please help

    tq
    Last edited by i_len2884; 2006-04-12 at 04:28 AM.

  6. #6
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,217

    Default Re: How to connect data in Excel to Block inside Modelspace

    Quote Originally Posted by i_len2884
    Set objnewss = objDoc.SelectionSets.Add("ONLYBLOCKS")
    On Error Resume Next
    Set objnewss = objDoc.SelectionSets("ONLYBLOCKS")
    Set objnewss.clear
    On Error GoTo 0


    An error accured after "On Error Resume Next" please help

    tq
    Maybe this will work for you:
    Code:
        Dim objnewss As AcadSelectionSet
        Dim objSelColl As AcadSelectionSets
    
      With ThisDrawing
        Set objSelColl = .SelectionSets
        For Each objnewss In objSelColl
          If objnewss.Name = "ONLYBLOCKS" Then
            objSelColl.Item("ONLYBLOCKS").Delete
            Exit For
          End If
        Next objnewss
        Set objnewss = objSelColl.Add("ONLYBLOCKS")
      End With
    f.
    Last edited by fixo; 2006-04-12 at 08:53 AM.

  7. #7
    Member
    Join Date
    2006-03
    Posts
    14

    Unhappy Re: How to connect data in Excel to Block inside Modelspace

    hi fixo,
    thanks so much that u helped me with your code.my code can run successfully now.even after i close the autocad and try to run it again,it works successfully.thank you.
    i wonder if you could help me with the data base connection.

    here my code:
    Code:
    dim con as adodb.connection
    dim rsdata as adodb.recordset
    con.CursorLocation = adUseClient
    con.open"Provider =Microsoft.Jet.OLEDB.4.0;Data Source...."
    
    ' Process each block in the selection Set objnewss
       For Each objEntity In objnewss
    
          For intRowCounter = 0 To lstResults.Rows - 1
            
            'Set the Row to the Counter
            lstResults.Row = intRowCounter
            
            ' Set the Colum to block name
            lstResults.Col = 0
            
            ' check for a match of the Block name and the text Value in the grid
            If objEntity.Name = lstResults.Text Then
                        
              ' set the Column to Count
              lstResults.Col = 1
              
              ' add one to the Quantity in the Count Column
              lstResults.Text = CDbl(lstResults.Text) + 1
              GoTo ExitProcessing
            End If
            
            
          Next
          
            ' addition of New block to the Flex grid
            ' set the rowlocation to the number of current rows..
            '(0 = 1 in grid world)
            intRowLocation = lstResults.Rows
            ' add a row to the Results FlexGrid
            lstResults.Rows = lstResults.Rows + 1
            lstResults.Row = intRowLocation     ' Setup the Row location
            lstResults.Col = intColBlock        ' Set the Column to the Block colum
            lstResults.Text = objEntity.Name    ' Place the Block text name into the FlexGrid
            rsdata.open"select from MyTable where TreeName ="+lstResults.text,con,adopenstatic,adlockReadonly,adcmdtext
    ''''how to code if lstResults.text = TreeName then insert Quantity into MyTable?
    ''''how to Select * from MyTable (after inserted Quantity) and display in the lstResults.grid?
    
           lstResults.Col = intColCount        ' Set the Column to the Count column
            lstResults.Text = "1"               ' Place "1" into the FlexGrid in the count column
    
            
    ExitProcessing:
           
            
     ' end of for
      Next
      
      
      
      ' sort the FlexGrid on the block column
      lstResults.Col = intColBlock
      lstResults.Sort = flexSortGenericAscending ' Sort the FlexGrid Assending
        
      ' Make the FlexGrid Visible
      lstResults.Visible = True
       
        ' make the Remove button and Place button enabled or disabled
        If lstResults.Rows <= 1 Then
           cmdRemove.Enabled = False
           cmdMtextPlace.Enabled = False
           Else
           cmdRemove.Enabled = True
           cmdMtextPlace.Enabled = True
        End If

    any help from you out there would be really great.i've been doing this part for 2 weeks already and havent got any clue frm anyone.please sumone out there help me.im clueless..Thanks for sharing your thoughts.Code sample would be better.Thanks.

    [ Moderator Action = ON ] What are [ CODE ] tags... [ Moderator Action = OFF ]
    Last edited by Opie; 2006-04-12 at 05:33 PM. Reason: [CODE] tags added, see moderator comment

  8. #8
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,217

    Default Re: How to connect data in Excel to Block inside Modelspace

    Sorry buddy Ican't to help you with it
    because I am newbee in VBA too and I haven't in my
    Windows FlexGrid.ocx or MsFlexGrid.ocx files to work
    with Flexgrid form



    f.

  9. #9
    I could stop if I wanted to
    Join Date
    2002-02
    Location
    Kansas
    Posts
    482

    Default Re: How to connect data in Excel to Block inside Modelspace

    Quote Originally Posted by i_len2884
    Set objnewss = objDoc.SelectionSets.Add("ONLYBLOCKS")
    On Error Resume Next
    Set objnewss = objDoc.SelectionSets("ONLYBLOCKS")
    Set objnewss.clear
    On Error GoTo 0


    An error accured after "On Error Resume Next" please help

    tq
    should be
    Code:
     
    On Error Resume Next
    Set objnewss = objDoc.SelectionSets.Add("ONLYBLOCKS")
    Set objnewss = objDoc.SelectionSets("ONLYBLOCKS")
    On Error GoTo 0
    Set objnewss.clear
    Note:
    update to 2011
    I am using ADT 2007 08/06/2008

    PS. If you use any Code I post or Down Load Attachment I would like to know if it was helpful. So please post reply to this thread, on how you use the code or down load. Thank You

  10. #10
    Member
    Join Date
    2006-03
    Posts
    14

    Wink Re: How to connect data in Excel to Block inside Modelspace

    thanks..it works..
    how can i store the block name and the quantity i got from the resultgrid.text into the access database in the field (blockname and quantity)?
    rsplant.open "insert into mytable (blockname) values= "&resultgrid.text&con,adopendynamic,adlockoptimistic,adcmdtable
    rsplant.open "insert into mytable (quantity) values= "&resultgrid.text&con,adopendynamic,adlockoptimistic,adcmdtable

    and one more thing..how can i search into the Access database for the same blockname(resultgrid.text) i get from the autocad?

    if the matched name found,how to select the row and put it display in the resultgrid?
    i would appreciate for a sample code.thanks..

Page 1 of 2 12 LastLast

Similar Threads

  1. Can't connect data table to excel spreadsheet
    By glenn22 in forum AutoCAD Map 3D - Data Connect (FDO)
    Replies: 7
    Last Post: 2010-05-18, 03:16 PM
  2. Extract Title Block Attribute Data to Excel
    By bzrqmy in forum AutoCAD Customization
    Replies: 6
    Last Post: 2008-12-03, 07:57 AM
  3. Populate Attirbute Block data from Excel
    By avn in forum AutoCAD General
    Replies: 1
    Last Post: 2006-07-07, 04:56 PM
  4. I am unable to connect excel to AutoCAD
    By avinash00002002 in forum VBA/COM Interop
    Replies: 1
    Last Post: 2006-03-16, 11:03 PM
  5. Replies: 2
    Last Post: 2005-07-27, 05:45 PM

Posting Permissions

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