PB with VBA Newsheet4. Inserts a sheet into a drawing, but does not display the selected basemap. Forced to manually charge it from SW

Under Sw 2015 and later, I can't get the VBA Newsheet3 or Newsheet4 instructions to insert a new sheet into a drawing from a VBA macro:

The sheet is indeed created with the specified background but it does not appear. I need to open the drawing in sw, do leaf properties/reload so that it appears.

Note that with the examples of Macros provided in the help it doesn't work either.

Is there the beginning of a solution?

Thank you

 

Hello

In the example of help: http://help.solidworks.com/2015/english/api/sldworksapi/Create_Drawing_Sheet_Zones_Example_VB.htm

They use the swModel.ForceRebuild3 method with the True step:

swModel.ForceRebuild3 True

 

This corresponds to "reload".

Hello 

I tried this track, it doesn't work better, I also tried to redo a setupSheet, also to edit the fdp from vba, but it doesn't do it!!

Thank you anyway

A+

Hello

If your basemaps are customized, you must retrieve the information from the original sheet because from memory SW relies on the default templates.

Look at swSheet.GetProperties in the API Help.

1 Like

Hello

Yes, these are custom basemaps, but the templates are available on 1 server  and  in the settings of the new sheet I specify the right path, by the way  NewSheet3 worked very well under sw2014 with the same parameters before the appearance of the areas on the map sheets (configurable in New Sheet4).

on the other hand if I use NewSheet3 (without the Zones) in sw2015 it doesn't work any better. There is a change that I cannot determine.

Maybe someone has recently used newshhet4 successfully, it would be interesting to have his feedback.

In attachment the properties of the inserted sheet (everything seems normal to me) and I checked by getTemplateName the right fdp is well taken into account.

 


sheetprop_feuille_inseree.jpg

For my part I am under 2016, with the line below it works without problems:

     boolstatus = swDraw.NewSheet4("Test", swDwgPaperA3size, swDwgTemplateCustom, 1, 1, True, "xxx:\SOLIDWORKS TEMPLATES\Basemaps\a3.slddrt", 0, 0, "", 0.5, 0.5, 0.5, 0.5, 0, 0)
 

1 Like

Thank you Cyril, 

In fact I just found that SW can't reload the FDP when the new sheet is of the same format and orientation as the previous one. When you choose a different  format, it works.

I solved my pb by deliberately inserting a misoriented sheet and then turning it over with a setupsheet.

my code in PJ.

Thank you 

A+


fonctionne.txt

Surprising because the line I put and the file I tested on was A3 for A3.

1 Like

Hello

Cyril.f's line also works very well for me, be.adl there is one thing that surprises me a bit in your code example, you define a swDraw variable as a DrawingDoc but you work on the Part variable that you defined as a ModelDoc2 in your NewSheet3 and SetupSheet5 functions, is this voluntary and would the difference in operation come from there?

Kind regards

Hello

In fact, going back to Modeldoc2  or drawingDoc allows me to have access to activateSheet() for the new sheet created o. I haven't checked if it's really necessary but it works like that.

As for the operation of Newshhet4(), for me it only stutters when the new sheet inserted has the same format and orientation as the sheets already present in the original document.

Regards A+