VLAX.cls

VLAX.cls

Anonymous
Not applicable
1,104 Views
7 Replies
Message 1 of 8

VLAX.cls

Anonymous
Not applicable

Hi,

 

I have an old vba macro that uses VLAX.cls to execute a lisp routine & pass the pagesetup name for the current sheet to vba. This routine has worked fine for many releases but I've just upgraded to 2015 & VLAX seems to be crashing Autocad. Anyone using VLAX.cls in 2015? I'm pretty sure you still can't access the curent page setup name thru VBA. Is there an updated version of VLAX? Can anyone suggest an alternative method of achieving the same thing? Thanks in advance.

 

 

Public Function GetCurrentPlotConfig(LayoutName As String)
'Returns the name of the current PlotConfig for the specified layout
'Must do this though lisp because vba does not expose this property.
'
Dim VL As VLAX
Dim strPC As String
Set VL = New VLAX
'make sure lisp function (CurrentPlotConfig) is loaded
VL.EvalLispExpression ("(if (null CurrentPlotConfig)(load ""CurrentPlotConfig.lsp""))")
strPC = "(CurrentPlotConfig """ & LayoutName & """)"
strPC = VL.EvalLispExpression(strPC)
Set VL = Nothing
GetCurrentPlotConfig = strPC
End Function

 

LISP ROUTINE

(defun CurrentPlotConfig (strLayout / layts layt pconfig )
;;; this function is used with vba.
;;; vba does not expose Page Setup Name. It is stored
;;; as the (1 . "name") of (100 . "AcDbPlotsettings") subgroup
;;; of the "ACAD_LAYOUT" named object dictionary.
(vl-load-com)
(setq layts (dictsearch (namedobjdict) "acad_layout"))
(setq layt (dictsearch (cdar layts) strLayout))
(setq pconfig (cdr (assoc 1 layt)))
)

0 Likes
1,105 Views
7 Replies
Replies (7)
Message 2 of 8

owenwengerd
Advisor
Advisor

I'm no VBA expert, but I think it should be trivial to access the database directly from VBA in exactly the same way the lisp code does.

--
Owen Wengerd
ManuSoft
0 Likes
Message 3 of 8

Ed__Jobe
Mentor
Mentor

Hello, Owen,

Unfortunately, the VBA object model doesn't provide access to the NOD. That's why I wrote the code above. I just checked the 2015 object model and it hasn't been updated, so we have to use lisp to get at the NOD.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 4 of 8

Ed__Jobe
Mentor
Mentor

Hello ZX,

You need to go to the Initialize method of the vlax.cls module and make sure that vlax is getting set to VL.Application.16.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 5 of 8

owenwengerd
Advisor
Advisor

@eljobe wrote:

Unfortunately, the VBA object model doesn't provide access to the NOD.


Have you tried ThisDrawing.Dictionaries?

--
Owen Wengerd
ManuSoft
0 Likes
Message 6 of 8

Ed__Jobe
Mentor
Mentor

@owenwengerd wrote:

@eljobe wrote:

Unfortunately, the VBA object model doesn't provide access to the NOD.


Have you tried ThisDrawing.Dictionaries?


No, I missed that api. I haven't used the above code in years, but I'll look into it. I use c# now for my page setup stuff.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 7 of 8

Ed__Jobe
Mentor
Mentor

Hi Owen, the Dictionaries collection just provides a lower level access. The same is returned by ThisDrawing.Layouts as if you drilled down into dictionary items. The problem is that the Layout api doesn't provide access to all the fields of the table record.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 8 of 8

owenwengerd
Advisor
Advisor

@eljobe wrote:

Hi Owen, the Dictionaries collection just provides a lower level access. The same is returned by ThisDrawing.Layouts as if you drilled down into dictionary items. The problem is that the Layout api doesn't provide access to all the fields of the table record.


I did a quick test, and I see what you mean. The AcadLayout.Name property hides the base class' AcadPlotConfiguration.Name in the VBA object model.

--
Owen Wengerd
ManuSoft
0 Likes