Temporary acessible memory in CATIA-V5

Michal Olszewski

Temporary acessible memory in CATIA-V5

this is my first post in this forum so I would like to thanks administration and all active users for knowledge that I have received from here

I am CAD Designer who additionaly develops VBA macros for CATIA V5
At the moment I am working on tool which uses WINAPI Timer to make smoth Viewer centering on CATDrawing object(like CATIA option "Reframe On")

- Macro uses Timer to change ActiveViewer.ViewPoint2D XYcoordinates 25times [OK]
- At the end Timer is destructed by WINAPI method KillTimer [OK]
- If VBA functionality is interrupted then TimerID is lost. Without knowing of TimerID Timer cannot be terminated [NOK]
- When timer is set and continously pushes VBA method any further VBA error causes CATIA crash [NOK]

I am wondering if there is any temporary location in CATIA (not related with Active Document) which could temporary store TimerID(Long)
Location have to be fast acessible, I cannot use something like CATIA.Documents.Add

At the moment I am using MicrosoftScriptingRunTime to save TimerID as text file (sPath = "C:\Users" & Environ("username") & "") but I am affraid this path could be not accesible for some people.

Little Cthulhu

RE: Temporary acessible memory in CATIA-V5
(in response to Michal Olszewski)

Use CATIA.SystemService.Environ("CATTemp") directory to store temporary files with persistency between CATIA sessions. You don't really want to stick to any memory resided in a single CATIA process since it may crash and timers ID is going to be lost.

Just a little side note, if I may. Timers in VBA are pretty dangerous and should be avoided unless absolutely necessary. In your case having smooth zooming improves users experience but offers no actual functionality. That being said, I would recommend getting rid of a timer completely. 

Consider running infinite loop with DoEvents call instead.