Global Variables disappear!

Global Variables disappear!

Anonymous
Not applicable
259 Views
5 Replies
Message 1 of 6

Global Variables disappear!

Anonymous
Not applicable
Hello Again!

This is my new problem:

I've A public variable in Vba : A = 1

If I call a visual lisp routine, when it come back to Vba , My variable A is
resetted!

Is it normal to lose the variables after a Visual lisp call?
Thank you!
Pivanti Marco
0 Likes
260 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
No, it is not normal. I suspect you have declared your variable with the
wrong scope. Perhaps you can post some code.

--
Get free software and more at http://www2.stonemedia.com/~franko

"Maverick" wrote in message
news:8745f1$a397@adesknews2.autodesk.com...
> Hello Again!
>
> This is my new problem:
>
> I've A public variable in Vba : A = 1
>
> If I call a visual lisp routine, when it come back to Vba , My variable A
is
> resetted!
>
> Is it normal to lose the variables after a Visual lisp call?
> Thank you!
> Pivanti Marco
>
>
0 Likes
Message 3 of 6

Anonymous
Not applicable
Ok: This is some code:

Public Layer_Terreno As AcadLayer
Public Layer_Sostegni As AcadLayer
Public Layer_Altro As AcadLayer
Public Layer_Vincoli As AcadLayer
Public Layer_Franco As AcadLayer
Public Layer_Righello As AcadLayer
Public PI As Double

Public Hatch_Solido As AcadHatch

Public FrontView As AcadViewport
Public TopView As AcadViewport

Public Fondamentale As Double

Public KX As Single
Public KY As Single

Public isFile as boolean
Public actPath as string

Private Sub AcadDocument_Activate()

actPath = "m:\marco\enel3d"

KX = 1
KZ = 1

IsFile = False

ThisDrawing.SetVariable "CURSORSIZE", 100
PI = 4 * Atn(1)

Set Hatch_Solido = ThisDrawing.ModelSpace.AddHatch _
(acHatchPatternTypePreDefined, "ANSI31", True)

Set Layer_Terreno = ThisDrawing.Layers.Add("Terreno")
Layer_Terreno.Color = acGreen
Set Layer_Sostegni = ThisDrawing.Layers.Add("Sostegni")
Layer_Sostegni.Color = acWhite
Set Layer_Vincoli = ThisDrawing.Layers.Add("Vincoli")
Layer_Vincoli.Color = acRed
Set Layer_Altro = ThisDrawing.Layers.Add("Altro")
Layer_Altro.Color = acYellow
Set Layer_Franco = ThisDrawing.Layers.Add("Franco")
Layer_Franco.Color = acBlue
Set Layer_Righello = ThisDrawing.Layers.Add("Righello")
Layer_Righello.Color = acGreen

end sub

This routine, set my variables when the acad is start.
subsequently, from the menù the user click on this routine:

sub Mmodifica()

frm_Modifica_Sostegno.show ' It's a Form

end sub

The form called have a button that call a visual lisp routine:

(defun c:disdima (/)
(... this function draw a matematical function tracking the mouse ...)

(command "_-vbarun")
(command "Getcoord")
)

When the lisp function ends call a Vba routine that read the coordinates
from a file... but when I'm return in VBA the global variables are all
disappeard (This thing also happen when an error occur and I click on the
end button!).

Have you need of other information?
0 Likes
Message 4 of 6

Anonymous
Not applicable
I don't know how A2K is affected, but in R14 you need to close the IDE
window while running a procedure or you can lose global variables.
Hope this helps,

- Adam
0 Likes
Message 5 of 6

Anonymous
Not applicable
I must confess Maverick, I am confused. How do you expect to run a LISP
routine from a VBA form? Also, when you say your globals have disappeared,
are yousaying your layers (along with the other public objects) are empty?

"Maverick" wrote in message
news:8764ar$ia66@adesknews2.autodesk.com...
> Ok: This is some code:
>
> Public Layer_Terreno As AcadLayer
> Public Layer_Sostegni As AcadLayer
> Public Layer_Altro As AcadLayer
> Public Layer_Vincoli As AcadLayer
> Public Layer_Franco As AcadLayer
> Public Layer_Righello As AcadLayer
> Public PI As Double
>
> Public Hatch_Solido As AcadHatch
>
> Public FrontView As AcadViewport
> Public TopView As AcadViewport
>
> Public Fondamentale As Double
>
> Public KX As Single
> Public KY As Single
>
> Public isFile as boolean
> Public actPath as string
>
> Private Sub AcadDocument_Activate()
>
> actPath = "m:\marco\enel3d"
>
> KX = 1
> KZ = 1
>
> IsFile = False
>
> ThisDrawing.SetVariable "CURSORSIZE", 100
> PI = 4 * Atn(1)
>
> Set Hatch_Solido = ThisDrawing.ModelSpace.AddHatch _
> (acHatchPatternTypePreDefined, "ANSI31", True)
>
> Set Layer_Terreno = ThisDrawing.Layers.Add("Terreno")
> Layer_Terreno.Color = acGreen
> Set Layer_Sostegni = ThisDrawing.Layers.Add("Sostegni")
> Layer_Sostegni.Color = acWhite
> Set Layer_Vincoli = ThisDrawing.Layers.Add("Vincoli")
> Layer_Vincoli.Color = acRed
> Set Layer_Altro = ThisDrawing.Layers.Add("Altro")
> Layer_Altro.Color = acYellow
> Set Layer_Franco = ThisDrawing.Layers.Add("Franco")
> Layer_Franco.Color = acBlue
> Set Layer_Righello = ThisDrawing.Layers.Add("Righello")
> Layer_Righello.Color = acGreen
>
> end sub
>
> This routine, set my variables when the acad is start.
> subsequently, from the menù the user click on this routine:
>
> sub Mmodifica()
>
> frm_Modifica_Sostegno.show ' It's a Form
>
> end sub
>
> The form called have a button that call a visual lisp routine:
>
> (defun c:disdima (/)
> (... this function draw a matematical function tracking the mouse ...)
>
>
> (command "_-vbarun")
> (command "Getcoord")
> )
>
> When the lisp function ends call a Vba routine that read the coordinates
> from a file... but when I'm return in VBA the global variables are all
> disappeard (This thing also happen when an error occur and I click on the
> end button!).
>
> Have you need of other information?
>
>
>
0 Likes
Message 6 of 6

Anonymous
Not applicable
>I must confess Maverick, I am confused. How do you expect to run a LISP
>routine from a VBA form?

I must run a Lisp routine from VBA for the old discussion of the tracking
mouse.
I don'have in vba the mousemove event , in lisp i use "grread" and get the
mouse coordinates tracked on the screen, then I use a lisp routine for draw
my function in real time tracked by mouse. When the user click on a point,
My lisp routine ends and pass the coordinate point to VBA.
I Assure you that now is all resolved!

>Also, when you say your globals have disappeared,
>are yousaying your layers (along with the other public objects) are empty?

The only problem is that when I return from VLisp I find all of my global
variables Resetted (Empty or =0) and also my object handling layers
resetted...

I'have however resolved Saving my variabled into a file and subsequently
refresh them with this file.

Bye Maverick!
0 Likes