Vlax.cls concerns

Vlax.cls concerns

Anonymous
Not applicable
735 Views
5 Replies
Message 1 of 6

Vlax.cls concerns

Anonymous
Not applicable
I’m interested in learning how to use the Vlax.cls functions in my programs. I have two concerns that I’m having trouble with. I’ve found that I if I don’t comment out the first 9 lines in the Vlax.cls code I get the error message “Compile error: Expected end of statement”. The VBA code seems to run fine with these lines commented out.
I’ve attached a small program with a VBA form to test the Vlax.cls functions. I get the command line error message “Execution error” when VBA ends and AutoLISP resumes. I’m fairly new to VBA and I’m hoping that someone will look into my small program and help me.
[code]
(defun c:VE1 (/ Entity Entitylist EntitySelect TextHeight TextValue)
(if (setq EntitySelect (entsel "\nSelect text to edit and change height: \n"))
(if (= (cdr (assoc 0 (entget (car EntitySelect)))) "TEXT")
(progn
(setq Entity (car EntitySelect))
(setq Entitylist (entget Entity))
(setq TextValue (cdr (assoc 1 Entitylist)))
(setq TextHeight (cdr (assoc 40 Entitylist)))
(command "vbaload" "VlaxExample1.dvb")
(command "vbarun" "thisdrawing.Main")
(command "vbaunload" "VlaxExample1.dvb")
(setq Entitylist (entmod (subst (cons 1 TextValue) (assoc 1 Entitylist) Entitylist)))
(setq Entitylist (entmod (subst (cons 40 TextHeight) (assoc 40 Entitylist) Entitylist)))
(entupd Entity)
(princ "\nObject updated.")
)
(princ (strcat "\nObject selected was " (cdr (assoc 0 (entget (car EntitySelect))))))
)
)
(princ)
)
[/code]
[code]
Option Explicit
Private Sub UserForm_Initialize()
Dim vl As New VLAX
Dim dblVal As Double
Dim strVal As String
strVal = vl.GetLispSymbol("TextValue")
dblVal = vl.GetLispSymbol("TextHeight")
txtTextValue.Text = strVal
dblTextHeight.Text = CStr(dblVal)
txtTextValue.SetFocus
End Sub
Private Sub cmdOK_Click()
Dim vl As New VLAX
vl.SetLispSymbol "TextValue", txtTextValue.Text
vl.SetLispSymbol "TextHeight", CDbl(dblTextHeight.Text)
End
End Sub
Private Sub cmdCancel_Click()
End
End Sub
[/code]
The 9 lines I commented out in Vlax.cls
[code]
'VERSION 1.0 CLASS
'BEGIN
' MultiUse = -1 'True
'End
'Attribute VB_Name = "VLAX"
'Attribute VB_GlobalNameSpace = False
'Attribute VB_Creatable = False
'Attribute VB_PredeclaredId = False
'Attribute VB_Exposed = False
[/code]
0 Likes
736 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
That VLAX.CLS....it appears that you pasted it into a module, correct? That
is not what you need do.....instead, Import the CLS file under File->Import
which will create the correct class module with the correct code.

Second, the file usually found was written back in the R2000/2002 days. The
InterfaceObject needs to be revised for newer versions:
"VL.Application.16" ....this works for r2004-2008

HTH,
Jeff

"K.Nugent" wrote in message news:5782887@discussion.autodesk.com...
I’m interested in learning how to use the Vlax.cls functions in my programs.
I have two concerns that I’m having trouble with. I’ve found that I if I don’t
comment out the first 9 lines in the Vlax.cls code I get the error message
“Compile error: Expected end of statement”. The VBA code seems to run fine
with these lines commented out.
I’ve attached a small program with a VBA form to test the Vlax.cls
functions. I get the command line error message “Execution error” when VBA
ends and AutoLISP resumes. I’m fairly new to VBA and I’m hoping that someone
will look into my small program and help me.
0 Likes
Message 3 of 6

Anonymous
Not applicable
Thanks for your tip on the File > Import method. Yes, I had created a class named VLAX and pasted in the code. I just did a compare of the code in the File > Import method and the code in the paste method and the only difference was that the code in the File > Import method didn’t have the top 9 lines. Thanks again. As per the VL.Application.16 issue, this was already in the VLAX.cls version that I downloaded from this site. I am using AutoCAD 2005. I seem to remember browsing around and found a version that in that section of the code it was checking for the AutoCAD version and set either VL.Application.16 or VL.Application.1. I like that idea.

Regarding the command line error message “Execution error” when VBA ends and AutoLISP resumes, is there something that I may be doing wrong that is causing this error or is this suppose to happen?
0 Likes
Message 4 of 6

Anonymous
Not applicable
You're welcome!

To remove the Execution Error, remove the End statements from your code.
Replace them with Unload Me:

Private Sub cmdOK_Click()
Dim vl As New VLAX
vl.SetLispSymbol "TextValue", txtTextValue.Text
vl.SetLispSymbol "TextHeight", CDbl(dblTextHeight.Text)
Unload Me
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub

"K.Nugent" wrote in message news:5783684@discussion.autodesk.com...
the command line error message “Execution error” when VBA ends and AutoLISP
resumes, is there something that I may be doing wrong that is causing this
error or is this suppose to happen?
0 Likes
Message 5 of 6

Anonymous
Not applicable
Thanks so much. This reminds me of when I was first learning AutoLISP. I was so happy when I finally figured out how to suppress the "nil" on the command line by placing a (princ) as the last line in the code.
Thanks again!

By the way here's that revision of that subfunction. Does it look right to you?

[code]
Private Sub Class_Initialize()

If Left(ThisDrawing.Application.Version, 2) = "15" Then
Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
ElseIf Left(ThisDrawing.Application.Version, 2) = "16" Then
Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
End If
Set VLF = VL.ActiveDocument.Functions

End Sub
[/code] Added subfunction Private Sub Class_Initialize.
Message was edited by: K.Nugent
0 Likes
Message 6 of 6

Anonymous
Not applicable
Glad I could help!
That new Sub looks fine to me.

Have a good Thanksgiving, if you are in the U.S., otherwise have a good
Thursday! 🙂

"K.Nugent" wrote in message news:5783731@discussion.autodesk.com...
Thanks so much. This reminds me of when I was first learning AutoLISP. I was
so happy when I finally figured out how to suppress the "nil" on the command
line by placing a (princ) as the last line in the code.
Thanks again!

By the way here's that revision of that subfunction. Does it look right to
you?
0 Likes