Results 1 to 8 of 8

Thread: Vb.net

  1. #1
    Member
    Join Date
    2015-10
    Posts
    5


    Default Vb.net

    Hi AUGI,

    I am very new in the world of autocad customization via VB.net. Can I seek your help how can I extract those object in autocad to excel using vb.net. I know there is a -dataextraction command, but they requires me to automate using vb.net. My goal is to extract to excel the "Line" properties Layers, Length and the hyper link.

    Thanks all in advanced.

  2. #2
    Forum Manager, Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,319


    Default Re: Vb.net

    Quote Originally Posted by keith_r View Post
    but they requires me to automate using vb.net.
    Does that mean you don't know vb or you would rather use another language.
    C:> ED WORKING....

  3. #3
    Member
    Join Date
    2015-10
    Posts
    5


    Default Re: Vb.net

    Quote Originally Posted by Ed Jobe View Post
    Does that mean you don't know vb or you would rather use another language.
    I know mate I can handle vb, but api in autocad is not that much experienced.

  4. #4
    Forum Manager, Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,319


    Default Re: Vb.net

    OK, then I'll move this to the DotNet forum where you might get some more help.

    To get you started, try searching this forum for "Excel". It delivers a lot of threads. You search a forum by clicking on the forum link to view the forum, then finding the Search box at the right.

    First, create yourself a flowchart of what steps you need to perform, then search this forum for sample code to study using keywords in your flowchart as search terms. That should help you learn what you need. I assume that you have used AutoCAD. Here is a link to the online developer documentation.

    Some basic step you might need:
    Prompt the user for a selection set
    Get a running instance of Excel
    Get a Sheet object
    Get a Range object
    Iterate the SelectionSet items and collect their properties.
    Write the properties to the Range

    Items in the SelectionSet would be of type AcadEntity. You can examine their class to check what subtype they are, e.g. Line, Circle, etc. or you can use a Filter on the SelectionSet to force the user to select only objects of a certain type.
    Last edited by Ed Jobe; 2017-04-03 at 03:30 PM.
    C:> ED WORKING....

  5. #5
    Member
    Join Date
    2015-10
    Posts
    5


    Default Re: Vb.net

    Now I can extract those Line object properties that I needed "Layer" "Length", my only problem is the "HyperLink" the purpose of hyperlink to distinguish a line I use the hyperlink text description to put a name in an object which now I cannot extract.

    strLink = vAcadLine.Hyperlinks =====> error please help me to code for the syntax to write on this
    strLine = vAcadLine.Length
    strLayer = vAcadLine.Length

  6. #6
    Forum Manager, Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,319


    Default Re: Vb.net

    Hyperlinks is a collection. You need to refer to an item in the collection. Typically there is only one item, so:
    strLink = vAcadLine.Hyperlinks(0).Name
    C:> ED WORKING....

  7. #7
    Member
    Join Date
    2015-10
    Posts
    5


    Default Re: Vb.net

    many thanks mate for your responsive replies, I really appreciate it. Maybe I used the hyperlink in a wrong way or is it possible? those hyperlinks were place in the line objects. Basically only line objects has a hyperlink to it and want to get the text description. I would like to share also my code in getting the line properties, where should I put the line code you mentioned and should I define also a variable for hyperlink as hyperlink collection? hyperlink description should be inside the select case statement to align in extracting to excel.

    Code:
     For lngCounter = 0 To lngEntities - 1
                        objEntity = vAcadDoc.ModelSpace.Item(lngCounter)
    
                        Select Case objEntity.ObjectName
                            '    'CORRECT
                            Case "AcDbLine"
                                vAcadLine = objEntity
                                strLine = vAcadLine.Layer
                                strLayer = vAcadLine.Length
                                If strLine.Trim <> "" And strLine.Length > 3 Or strLayer.Trim <> "" And strLayer.Length > 3 Then
                                    xlsSheet.Range("D" & lngEngTagRow).Value = strLine
                                    xlsSheet.Range("E" & lngEngTagRow).Value = strLayer
                                    lngEngTagRow += 1
                                End If
                        End Select
                    Next
    Last edited by Ed Jobe; 2017-04-05 at 02:27 PM.

  8. #8
    Forum Manager, Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,319


    Default Re: Vb.net

    I would make the following changes. Your variable names are confusing since they don't match the properties they contain.
    Code:
     For lngCounter = 0 To lngEntities - 1
                        objEntity = vAcadDoc.ModelSpace.Item(lngCounter)
    
                        Select Case objEntity.ObjectName
                            '    'CORRECT
                            Case "AcDbLine"
                                vAcadLine = objEntity
                                strLayer = vAcadLine.Layer
                                strLength = vAcadLine.Length
                                strLink = vAcadLine.Hyperlinks(0).Name   'Link URL
                                If strLayer.Trim <> "" And strLayer.Length > 3 Or strLength.Trim <> "" And strLength.Length > 3 Then
                                    xlsSheet.Range("D" & lngEngTagRow).Value = strLayer
                                    xlsSheet.Range("E" & lngEngTagRow).Value = strLength
                                    xlsSheet.Range("F" & lngEngTagRow).Value = strLink
                                    lngEngTagRow += 1
                                End If
                        End Select
                    Next
    C:> ED WORKING....

Posting Permissions

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