Problems with Snaps

#1
Hi,

I'm developing a new application for IntelliCAD based on VBA routines. But I have some external routines built in LISP. Precisely one of those, which returns the point selected by the user (PEDIRPUNTO routine), is causing some troubles. I have two different states, normal state, and insert process state. While I'm inserting a process, I need to pick up a point in ICAD where the process will be applied. For to get the point I call via a external call, the routine built in LISP that returns the point selected with the mouse. If I'm in the middle of the process of picking up a point, and using the snap Intersection, as soon as I pass the mouse over an intersection it brings up a message error, Operation Cancelled. Any idea? Any help will be much appreciated.

Thanks,
Mario.

Snippet of the routine PEDIRPUNTO code:
(defun C:PEDIRPUNTO (/ temperror ptIns)
(setq temperror *error*)
(setq *error* myerror)
(setvar "cmdecho" 0)
(setvar "USERI2" 1)
(setq ptIns nil)
(while (= ptIns nil) (setq ptIns (getpoint (strcat "\n" (getvar "USERS4")))))
(if (not (= ptIns nil)) (progn (setvar "USERR1" (nth 0 ptIns)) (setvar "USERR2" (nth 1 ptIns)) (setvar "USERI2" 0)))
(setvar "USERS4" "")
(setq *error* temperror)
(princ)
(princ)
(princ)
(princ)
(princ)
)

(defun myerror (msg)
(setvar "USERS4" "")
(setq *error* temperror)
(princ)
(princ)
(princ)
(princ)
(princ)
)

#2
Mario:

You can solve the whole shebang in VBA. The following routine will do what you require.

Option Explicit

Private Function PedirPunto()
Dim Pt As IntelliCAD.Point
Dim Doc As IntelliCAD.Document
Dim Util As IntelliCAD.Utility
Dim X As Double
Dim Y As Double

Set Doc = ActiveDocument
Set Util = Doc.Utility
On Error GoTo Fin
Set Pt = Util.GetPoint(, Chr(13) & "Seleccione la ubicación ...")
X = Pt.X: Y = Pt.Y
MsgBox "X= " & X & Chr(13) & "Y= " & Y, vbInformation + vbOKOnly, "Pedir
Punto"
Doc.SetVariable "USERR1", X
Doc.SetVariable "USERR2", Y

Exit Function
Fin:
MsgBox "Cancelado por el usuario"
End Function

A word of caution, you may have to disable the Flyover Snap feature as these do not work properly in VBA.

If you are using the routine from the command line the following auxiliary function will be necessary to force VBA to stop and pick the point.

Public Function Lapso(Optional PauseTime As Single)
Dim Start

If PauseTime = 0 Then
PauseTime = 0.3
End If
Start = Timer ' Set start time.
Do While Timer < Start + PauseTime
DoEvents ' Yield to other processes.
Loop
End Function

Lapso
Ancho = Util.GetDistance(, "Ingrese el Ancho ... ")

From your code I presume that you are working in Spanish. If you prefer to post your queries in Spanish, please do so at the Spanish Forum or drop me a line at topocalc@adinet.com.uy.

Good luck with your project!

Hector