How do I retrieve the format of a drawing in a solidworks macro?

Hello

 

I would like to change the background of a macro drawing (new background plan template) but to do so I need to know what format my on-screen drawing is in.

(A0 or A1 or A2 or A3 or A4) this property is saved in my model under the name "DRAWING-CAD_SHEESIZE".

 

How do I retrieve this variable in a macro in order to then test its value to load the new basemap of the same size?

I just don't know how to recover the variable!!

 

Thanks in advance

 


format.jpg

If you have the mycadtools suite, this bulk modification is easily done via the INTEGRATION utility.

1 Like

No, I don't have this tool...

Hello

An answer here:

https://forum.solidworks.com/thread/67115

 

I'm starting out in VB with SolidWorks (I do VB with Excel but it's different)

I need something clear. (with declarations)

Can someone write me the lines of code (VB) in order to retrieve the value of my variable "DRAWING-CAD-SHEETSIZE".

I should get 'A3' in a variable.

 

Thank you for your help


format.jpg

Hello

Here is the code I use IN VBA:

'Sheet info retrieval
Dim ps As PageSetup
Set ps = swDraw.PageSetup
Set swSheet = swDraw.GetCurrentSheet
vSheetProps = swSheet.GetProperties
size = swSheet.GetSize(Width, Height)

Then I assign the format of the plane in a variable according to the dimensions retrieved.

Go to the API help, you'll find marbles by searching for "getsize"...

A +

1 Like

Thank you very mucho Glaffont

 

I was on the same track.

I got the properties of the sheet

vSheetProps = swSheet.GetProperties

The vSheetProps (0) returns a value between 6 and 11 depending on the size of the paper.

All you have to do is do a test on it and you're done.

 

Thank you

 

Re

If your format is already in a property, you can retrieve it this way (still in VBA):

Dim Part As IModelDoc2

Dim ValProp As String

ValProp = Part.GetCustomInfoValue("", "DRAWING-CAD_SHEESIZE")

 

In VB, it should look like this (but I can't test):

Dim instance as IModelDoc2
Dim Value As System.String

Value = instance. GetCustomInfoValue("","DRAWING-CAD_SHEESIZE")

 

But you're welcome,

The line size = swSheet.GetSize(Width, Height) also returns this value live.

I had duplicated the info because at the time I didn't know how to extract the values from vSheetProps (XX)

Have a nice day