See the top rated post in this thread. Click here

Results 1 to 5 of 5

Thread: LISP Debug Broken - Need Lisp to VBA Convert Help

  1. #1
    Login to Give a bone
    0

    Question LISP Debug Broken - Need Lisp to VBA Convert Help

    Having a mental block at the moment not sure I'm doing this right ... basically is the data structure i have in the JPG identical to that produced by the LISP? My LISP debugger isn't working correctly so I'm not sure.


    need some help converting these LISP statements to VB6:
    Code:
    (setq s1 '(0 0 0) s1a '(1 1 1)
    (setq pl_lst (append pl_lst (list (list s1 s1a)))
    Here is my attempt:
    Code:
    Public Sub pl_lstconvert()
      Dim s1 as Variant
      Dim s1a as Variant
      Dim pl_lst as New Collection
      Dim pl_sublist(1) as Variant
    
      s1 = MakePoint(0#, 0#, 0#)    'Note: MakePoint is a function I built to create a 3D point
      s1a = MakePoint(1#, 1#, 1#)
    
      pl_sublist(0) = s1: pl_sublist(1) = s1a
      pl_lst.add pl_sublist
    end sub
    Attached Images Attached Images
    Last edited by bsardeson; 2010-10-06 at 05:15 PM. Reason: Correct Code

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,606
    Login to Give a bone
    0

    Default Re: LISP Debug Broken - Need Lisp to VBA Convert Help

    LISP stand for LISt Processor. I think you're probably overdoing it trying to make vba use lists. What do you really want to do?
    C:> ED WORKING....

  3. #3
    Login to Give a bone
    0

    Arrow Re: LISP Debug Broken - Need Lisp to VBA Convert Help

    The snippet above is nothing more than my attempt for a literal translation of the LISP. If my VLISP interface debugger was working properly, I could easily compare the positions of the data in the LIST to that of the VB6 collection by counting the positions in the watch window. I just want to make sure I'm on the right track in building my multi-dimensional collection correctly. I can fix the debugger with a re-install; however, now isn't a good time to rebuild my PC and re-install everything.

    Now to answer your question Ed ...

    Quote Originally Posted by Ed Jobe View Post
    LISP stand for LISt Processor. I think you're probably overdoing it trying to make vba use lists. What do you really want to do?
    Realistically I'm iterating a several For Loops with potentially hundreds of point combinations for line placement and determining the resulting intersections. I need to track each iteration and store the resulting point pairs for later use in the code.

    The later formulas also perform functions to modify the X,Y, or Z of either one or both points in the pair depending on the resulting intersections or function results.

    Some pseudo code example:
    Code:
    For each oPair in pl_lst
      if distancebetweenpoints(oPair(0), oPair(1)) > 96 then
         oline = addline(oPair(0), makepoint(oPair(1)(0), oPair(1)(1) + 48#, oPair(2))
         pl2_sublist(0) = oline.startpoint
         pl2_sublist(1) = oline.endpoint
         pl2_lst = pl2_sublist
      else if distance > 48
        'do something to modify X'
        'save points
      else
         oline = addline(oPair(0), oPair(1))
         if referenceline.intersectswith(oline, extendboth) then
           pt2_sublist(0).add referenceline.intersectswith(oline, extendboth)
           pt2_sublist(1).add referenceline2.intersectswith(oline, extendboth)
           pl2_lst = pt2_sublist
         endif
      end if
    Next
    
    'Do something with the new points in pl2_lst

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    5,606
    Login to Give a bone
    1

    Default Re: LISP Debug Broken - Need Lisp to VBA Convert Help

    I made some changes. Use the collection's Add method to add more than one item. Depending on what you are doing with the points afterward, you might consider making objects from the points, rather than using variants. For example, using a Type or Class.
    Code:
    Public Sub pl_lstconvert()
      Dim s1 As Variant
      Dim s1a As Variant
      'Declare pl_lst in the Declarations section
      'to keep it global so you don't overwrite
      'it each time.
      'Dim pl_lst As New Collection
      Dim pl_sublist(1) As Variant
    
      s1 = MakePoint(0#, 0#, 0#)    'Note: MakePoint is a function I built to create a 3D point
      s1a = MakePoint(1#, 1#, 1#)
    
      pl_sublist(0) = s1: pl_sublist(1) = s1a
      pl_lst.Add pl_sublist
    End Sub
    C:> ED WORKING....

  5. #5
    Login to Give a bone
    0

    Default Re: LISP Debug Broken - Need Lisp to VBA Convert Help

    Quote Originally Posted by Ed Jobe View Post
    I made some changes. Use the collection's Add method to add more than one item.
    Whoops, my fault I knew that just didn't type it correctly, sorry.

    Quote Originally Posted by Ed Jobe View Post
    Depending on what you are doing with the points afterward, you might consider making objects from the points, rather than using variants. For example, using a Type or Class.
    The scope of pl_lst is entirely in one routine as of now. What type of object(s) would you suggest vs variants? Variants work now, but when I convert to .NET down the road, I know variants are not allowed.

    Current implementation of pl_lst:
    This loop creates construction lines and determines the intersection of these lines vs an existing construction line. Once all the intersection points are captured, I will later back fill with real lines, dimensions and polylines.
    Code:
    .
    .
    .
    Do While st < t1
            s1 = MakePoint(st, 0#, 0#)
            
            Set oXLine2 = oAcadDoc.ModelSpace.AddXline(s1, MakePoint(s1(0), s1(1) + 12#, s1(2)))    'AddXLine places points in World CS
            oXLine2.TransformBy oAcadDoc.ActiveUCS.GetUCSMatrix                                     'Transform back to UCS
            oXLine2.Color = acYellow
            oXLine2.Update
            
            s1a = cAcadTransCoords.TransCoordsFromWorldToUCS(oAcadDoc, oXLine2.IntersectWith(oXLine, acExtendNone)) 'Intersect Point is World, trans to UCS
            
            pl_sublist(0) = s1: pl_sublist(1) = s1a
            pl_lst.Add pl_sublist
            
            st = IIf(ctr = 0, st + dKerf, st + dMatlWidth)
            ctr = Abs(ctr - 1)
    Loop
    .
    .
    .

Similar Threads

  1. need a lisp to convert excel to autocad
    By drajraj4581136296 in forum AutoCAD Customization
    Replies: 6
    Last Post: 2015-07-13, 06:32 PM
  2. Convert old program to LISP
    By dandrejco in forum AutoLISP
    Replies: 3
    Last Post: 2012-10-12, 09:17 PM
  3. Convert LISP to DIESEL?
    By BlackBox in forum AutoCAD Fields
    Replies: 3
    Last Post: 2010-08-23, 08:40 PM
  4. How to convert Plot Lisp routine to VBA
    By ian.cook in forum VBA/COM Interop
    Replies: 3
    Last Post: 2006-07-10, 07:02 PM
  5. Convert LISP sub from metric?
    By IanR in forum AutoLISP
    Replies: 1
    Last Post: 2006-04-21, 01:31 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
  •