Consulting

Page 2 of 3 FirstFirst 1 2 3 LastLast
Results 21 to 40 of 53

Thread: Solved: VBA and AutoCAD reading points from a txt file?

  1. #21
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Can you post the files you are using?

  2. #22
    Ok I did the debug, see attachment, but its skipping over all the if statments for some reason.?
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  3. #23
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    That means the frames are not equal. The frames HAVE to start with the same number in both files.

  4. #24
    Oh shoot, ok let me fix......

    Thanks
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  5. #25
    Tommy thats awesome! Nice job!!

    Now I have a nice platform to work with, I will have to see if I have any doe in my paypal account,...just checked it but it only had like $3.00 left so I am going to transfer some doe in and make a donation to this web site within the next week or as soon as possible! You guys are the BEST!

    Rob

    PS Thanks to Fatty also.....always willing to help out as well!!
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  6. #26
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Glad we could Help
    Don't forget to mark it solved

  7. #27
    I will, but will that lock this tread?

    I am try too modify polylines to just a typical line:

    [VBA]
    'Dim mPoly As Acad3DPolyline
    Dim mPoly As AcadLine
    [/VBA]

    But this is giving me trouble:

    [VBA]
    If mStr > 0 Then Set mPoly = ThisDrawing.ModelSpace.Add3DPoly(FramArray)
    'If mStr > 0 Then Set mPoly = ThisDrawing.ModelSpace.Add3DPoly(FramArray)
    [/VBA]
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  8. #28
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    A quick and dirty:
    [VBA]
    If mStr > 0 Then
    Set mPoly = ThisDrawing.ModelSpace.Add3DPoly(FramArray)
    mPoly.Explode
    End If
    [/VBA]
    Otherwise you would need to rewrite the sub a lot.

  9. #29
    Right, actually a 3Dpolyline is fine. I got off track and was thinking it was a spline my bad.
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  10. #30
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Would you like to draw the whole frame instead of half the frame?

  11. #31
    Sure, since its code. Oh I think there are double lines going in not sure but zoom in at the ends and explode and erase then you will see what I mean.

    Its cool though...
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  12. #32
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Double line = double input

  13. #33
    Quote Originally Posted by Tommy
    Double line = double input
    Yup......my text file again....

    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  14. #34
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Whew glad it wasn't me. LOL I was thinking while I mowed the yard "I sure hope I don't have a sna-phoo"

  15. #35
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    This should give you the full frame.
    [VBA]
    'iFileName needs to contain the full path to the file with the extension
    Function OpenFile(iFileName As String) As Long
    Dim mFrFle As Long
    'Close
    mFrFle = FreeFile
    On Error GoTo OPPS
    Open iFileName For Input As #mFrFle
    OpenFile = mFrFle
    On Error GoTo 0
    Exit Function
    OPPS:
    MsgBox Err.Description
    Close mFrFle 'close the file you just tried to open and release the id
    Err.Clear
    End Function
    Sub ReadFileIntoArray()
    Dim ZId As Long, XYID As Long, mFrmNo As Long, mFrameLoc As Double
    Dim mXYFrmID As Long, mY As Double, mX As Double, mXYID As Long
    Dim FramArray() As Double, mStr As Long, mNextRec As Boolean, dum As String
    Dim mPoly As Acad3DPolyline
    ReDim FramArray(0)
    'Z cords
    ZId = OpenFile("C:\Projects\txt files and pics\Frame_Spacings.txt")
    'x and y
    XYID = OpenFile("C:\Projects\txt files and pics\Frame_Profiles.txt")
    mNextRec = True
    While Not EOF(ZId)
    Input #ZId, mFrmNo
    Input #ZId, dum, mFrameLoc
    If mNextRec Then Input #XYID, mXYID, dum
    While mXYID = mFrmNo
    If Not EOF(XYID) Then
    Input #XYID, mY, mX
    mStr = UBound(FramArray, 1)
    If mStr = 0 Then
    ReDim Preserve FramArray(mStr + 5)
    FramArray(mStr) = mX
    FramArray(mStr + 1) = mY
    FramArray(mStr + 2) = mFrameLoc
    FramArray(mStr + 3) = -mX
    FramArray(mStr + 4) = mY
    FramArray(mStr + 5) = mFrameLoc
    Else
    ReDim Preserve FramArray(mStr + 6)
    FramArray(mStr + 1) = mX
    FramArray(mStr + 2) = mY
    FramArray(mStr + 3) = mFrameLoc
    FramArray(mStr + 4) = -mX
    FramArray(mStr + 5) = mY
    FramArray(mStr + 6) = mFrameLoc
    End If
    If Not EOF(XYID) Then Input #XYID, mXYID, dum
    mNextRec = False
    Else
    mXYID = 500000
    End If
    Wend
    If mStr > 0 Then
    SortaPoint FramArray
    Set mPoly = ThisDrawing.ModelSpace.Add3DPoly(FramArray)
    End If
    ReDim FramArray(0)
    ZoomAll
    Wend
    End Sub
    'standard bubble sort for the points on the x plane
    Public Sub SortaPoint(MyPoints() As Double)
    Dim mTmp As Double
    Dim J As Integer
    Dim K As Integer
    Dim L As Integer
    J = UBound(MyPoints) '<- find the max number of points
    For K = 0 To J - 3 Step 3
    For L = K + 3 To J Step 3
    If MyPoints(K) > MyPoints(L) Then
    mTmp = MyPoints(K)
    MyPoints(K) = MyPoints(L)
    MyPoints(L) = mTmp
    mTmp = MyPoints(K + 1)
    MyPoints(K + 1) = MyPoints(L + 1)
    MyPoints(L + 1) = mTmp
    mTmp = MyPoints(K + 2)
    MyPoints(K + 2) = MyPoints(L + 2)
    MyPoints(L + 2) = mTmp
    End If
    Next
    Next
    End Sub

    [/VBA]

  16. #36
    Quote Originally Posted by Tommy
    I have some code that already does the decimal conversion from the format you posted, FYI.

    As Fatty said
    Tommy, would this code by any chance read it out of a pdf file?

    Its brutal typing in all this data, thats what I am doing now....
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  17. #37
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Ummm Adobe reader 8 has the option to save as text. Otherwise e-mail it to me and I'll see what I can do.

  18. #38
    Even if the data chart in the pdf file is a jpg, will it still convert that to a txt file? Because thats what I have.
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

  19. #39
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    No not that I am aware of.

    Go ahead and send it to me and let me see what I can do. I have a lot of tricks up me sleeve.

  20. #40
    Sent
    My {Tube Amp} Building Forum
    http://www.dreamtone.org/Forum/

Posting Permissions

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