+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12
  1. #1
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default LispToVBA VBAToLisp

    Registered forum members do not see this ad.

    Has anyone ever passed a Lisp variable into VBA and vice versa, sent a variable to ACAD from VBA?

    M

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

    Default

    You can save answers into a drawing for future using userr1 -4 (real) useri1 -4 integer users1 -4 strings

    Just getvar userr1 etc but if some else does this also can screw up things.

    This is simple I am sure there is a way

  3. #3
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default

    Hi Big
    Yeah, there was this real long VLAX.cls module out there.
    I muffled threw it some months ago and narrowed it down to two functions; they are GetLispSym and PutLispSym

    It really works well for string variables and integers.

    I don't use it a whole lot but on occasion, I may do something like (setq myvariable "whatever" ) in the mns/cui then in VBA, I may grab that variable if I need to do something.

    On the flip side, I may do something in VBA and fr some reason want the variable available in my CAD session, even after the VBA module is finished running, so I will then use PutLispSym

    I don't get too carried away with that stuff but it works well if I need it.

    I have also heard of users but I don't really like it, it is a bit limited.

    If you'd like to see the code, let me know

    Mark

  4. #4
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    Hi All

    that sound is good

    there is a VBA file wants to be a lisp

    how is this plz

    Thanx

  5. #5
    Super Member
    Using
    Architecture 2009
    Join Date
    Apr 2008
    Location
    London, (sunny UK)
    Posts
    686

    Default

    Quote Originally Posted by asos2000 View Post
    Hi All

    that sound is good

    there is a VBA file wants to be a lisp

    how is this plz

    Thanx
    Sorry, I am not sure that I understand. You have a VBA the you want to convert to lisp?

  6. #6
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    At first, thanx for quick replying

    Yes i have a VBA file want to convert to lisp

    Please find attached

    thanx
    Attached Files

  7. #7
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    Something like:

    Code:
    (defun c:ftxt(/ tObj dfxC tSet cPt tVal tStr vPt actDoc layCol nLay cTxt mSp cObj)
      (vl-load-com)
      (if(and(setq tObj(entsel "\nSelect text > "))
           (member(cdr(assoc 0(setq dfxC(entget(car tObj))))) '("TEXT" "MTEXT"))
           (setq tVal(cdr(assoc 1 dfxC)))
           ); end and
        (if(and
    	 (setq tSet(ssget "_X"(list '(0 . "TEXT,MTEXT")(cons 1 tVal))))
    	 (/= 1(sslength tSet))
    	 ); end and
          (if(setq cPt(getpoint "\nSpecify point > "))
    	(progn
    	  (setq tStr(strcat tVal ", Qnty = " (itoa(sslength tSet)))
    		actDoc(vla-get-ActiveDocument(vlax-get-acad-object))
    		layCol(vla-get-Layers actDoc)
    		); end setq
    	  (if(= 1(vla-get-ActiveSpace actDoc))
    	     (setq mSp(vla-get-ModelSpace actDoc))
    	     (setq mSp(vla-get-PaperSpace actDoc))
    	    ); end if
    	  (setq cTxt(vla-AddText mSp tStr(setq vPt(vlax-3D-point cPt))
    	    (vla-get-Height(vlax-ename->vla-object(car tObj)))))
    	  (if(not(vl-catch-all-error-p
    	           (setq nLay(vl-catch-all-apply 'vla-Add
    			    (list layCol "Qnty text")))))
    	                        (vla-put-Color nLay acBlue))
    	  (foreach txt(mapcar 'vlax-ename->vla-object
    		        (vl-remove-if 'listp 
                              (mapcar 'cadr(ssnamex tSet))))
    	    (if(= acAlignmentLeft(vla-get-Alignment txt))
    	      (setq cObj(vla-AddLine mSp vPt(vla-get-InsertionPoint txt)))
    	      (setq cObj(vla-AddLine mSp vPt(vla-get-TextAlignmentPoint txt)))
    	     ); end if
    	    (vla-put-Layer cObj "Qnty text")
    	    (vla-put-Layer cTxt "Qnty text")
    	    ); end foreach
    	  ); end progn
    	(princ "\nCommand canceled! ")
    	); end if
          (princ "\nNothing found! ")
          ); end if
        (princ "\nIt isn't Text or MText! ")
        ); end if
      (princ)
      ); end of c:ftxt

  8. #8
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    May 2008
    Location
    Philadelphia, Pa.
    Posts
    407

    Default

    Hey Guys

    AS, I am not too familiar with VLISP so I am not exactly sure what your code does. I am curious to know though

    The code I have is 2 functions that will allow you to grab a LISP (String or Integer) variables and use them in VBA
    and vice versa, it will allow you to send (String and Integer) variables also from VBA to LISP.

    So, for instance, if you ran your LISP routine first then the VBA module after that, the vba module can use the lisp variables and if you run your vba module first, you can then use the variables from VBA at the command line in ACAD or in a LISP routine.

    If you guys are interested, I will have to dig it up, then I will post it later. I think I have a few simple examples I can post too.
    If I can figure out how, I will post the whole project

    M

  9. #9
    Super Member asos2000's Avatar
    Computer Details
    asos2000's Computer Details
    Operating System:
    WinXP
    Using
    AutoCAD 2007
    Join Date
    Sep 2007
    Location
    Cairo Egypt
    Posts
    573

    Default

    What a quick reply
    That lisp is good

    But may I post some comments
    Plz find attached

    Thanx

    HaSaN
    Attached Files

  10. #10
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    Registered forum members do not see this ad.

    >ML0940
    Look to code for VBA<-> VisualLISP interchange:

    http://ww3.cad.de/foren/ubb/Forum259/HTML/000399.shtml

    > asos2000

    Not today.

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