VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Reply
Message 1 of 8
ZX_Spectrum_48k
722 Views, 7 Replies

VLAX.cls

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)))
)

7 REPLIES 7
Message 2 of 8

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
Message 3 of 8
Ed.Jobe
in reply to: owenwengerd

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

Message 4 of 8
Ed.Jobe
in reply to: ZX_Spectrum_48k

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

Message 5 of 8
owenwengerd
in reply to: Ed.Jobe


@eljobe wrote:

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


Have you tried ThisDrawing.Dictionaries?

--
Owen Wengerd
ManuSoft
Message 6 of 8
Ed.Jobe
in reply to: owenwengerd


@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

Message 7 of 8
Ed.Jobe
in reply to: Ed.Jobe

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

Message 8 of 8
owenwengerd
in reply to: Ed.Jobe


@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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost