Author Topic: (Challenge) Pass variable to VBA  (Read 4264 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Pass variable to VBA
« on: September 01, 2004, 04:00:08 PM »
Ok, I know it has been said before, we all have been told that it is not possible to send variables directly to VBA, but I am not willing to accept this.

The rules are .....
You must use LISP only to send values to VBA and VBA must be able to read the values and display them.
You may not use system variables such as USERxx, files to store and retrieve values or the registry
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
(Challenge) Pass variable to VBA
« Reply #1 on: September 01, 2004, 04:08:39 PM »
Is the COMMAND function off limits, also?

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
(Challenge) Pass variable to VBA
« Reply #2 on: September 01, 2004, 04:13:36 PM »
Well its not NOT possible, its just a pain in the a55.

But anyways... How about the Drawing itself?  Are you saying that you want only LISP (Is that just Autolisp, VisualLisp or both.)?

*edit: Took out a question cause you answered it. :P *
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Pass variable to VBA
« Reply #3 on: September 01, 2004, 04:19:09 PM »
the only things off limits are the registry, reading and writing to files and the USERxx variables. You can use any other system variables and or workarounds. VLisp, plain lisp and/or the command interface all may be used.

The winner will get the admiration programmers around the world....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

JohnK

  • Administrator
  • Seagull
  • Posts: 10646
(Challenge) Pass variable to VBA
« Reply #4 on: September 01, 2004, 04:38:27 PM »
Wait a min. I think we need to define how much data and what kind of data needs to be passed. If we are talking just one value of type string there really inst a big problem but if we are talking about "a list of layers" we are gonna have alot more code.  

And, i dont want 'admiration' so what else is there?
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

SMadsen

  • Guest
(Challenge) Pass variable to VBA
« Reply #5 on: September 01, 2004, 04:40:34 PM »
If COMMAND is allowed then there should be an example here

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(Challenge) Pass variable to VBA
« Reply #6 on: September 01, 2004, 04:44:35 PM »
Stig, have you tried that example....
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

SMadsen

  • Guest
(Challenge) Pass variable to VBA
« Reply #7 on: September 01, 2004, 04:51:04 PM »
Yes I have. It's not the greatest coding but the essence of it works.

Ron Heigh

  • Guest
(Challenge) Pass variable to VBA
« Reply #8 on: September 01, 2004, 04:54:41 PM »
can a user create a batch file from autocad then execute it to run the vba routine with the variables initialized and set?

SMadsen

  • Guest
(Challenge) Pass variable to VBA
« Reply #9 on: September 01, 2004, 04:55:10 PM »
Not sure what you mean by passing variables exactly but if it's just passing some values back and forth, it can be done with simple stuff like VBASTMT and SendCommand.

Another example

Code: [Select]
(defun sendValues ()
  (setq val1 (getdist "\nValue 1: ")
        val2 (getdist "\nValue 2: ")
  )
  (command "VBASTMT"
           (strcat "addValues " (rtos val1) ", " (rtos val2))
  )
)

(defun printResult (result)
  (princ result)
  (princ)
)

....

Public Sub addValues(v1 As Double, v2 As Double)
  Dim result As Double
  Dim astr As String
 
  result = v1 + v2
  astr = "(printResult " & result & ") "
  ThisDrawing.SendCommand astr
End Sub