Re: API: saveas dwg 1:1 scale output

Hello anyone,

> > Let's describe the problem. > I'm saving drawing as dwg file. That works fine. But I would like to > control the 1:1 scale setting as there is in the file format options. > > Anyone an idea how to do this with code? (vba) > > Johnny

you should be scaling it when opening it in autocad. but if you need to scale it in solidworks. i think you will have to use vb sendkeys and mouse_events. from what i can see there is no api for scaling dwg's

Reply to
Sean Phillips
Loading thread data ...

in message news:...

So there is no consitent way in saving dwg file using a macros. That would mean all other macro's are not able to handle this correctly. I don't believe it.

Can you help me to use the sendkey. How do I know what key combination I have to send to get the file export dialog box?

Johnny

Reply to
Johnny Geling remove: _removethis_

ThScale for all element can be set by API in VB. for the sheet scale use

Part.ClearSelection Part.SetupSheet4 "Sheet1", 12, 12, 1, 10, True, "D:\Drawing Templates\A3-TEMP.slddrt", 0.42, 0.297, "Default"

-The 1 and 10 are the sheet scale

Also look up in the API help file for the following functions.

"SetupSheet4" retval = DrawingDoc.SetupSheet4 ( name, paperSize, templateIn, scale1, scale2, firstAngle, templateName, width, height, propertyViewName )

"Scale2" Scale = PageSetup.Scale2 (VB Get property) PageSetup.Scale2 = Scale (VB Set property)

"ScaleDecimal" scale = View.ScaleDecimal (VB Get property) View.ScaleDecimal = scale (VB Set property)

"ScaleRatio" scale = View.ScaleRatio (VB Get property) View.ScaleRatio = scale (VB Set property)

-- Tony O'Hara Melbourne, Australia.

Reply to
Tony O'Hara

Wait a moment. Probably there is something I don't get. I use in SW different sheet scales to fit the models on drawing, mainly A4 size. In automatically producing the dwg files for including in our production system I use a vb script. During this translation (export) there is a manual option to assign the sheet scale (file export option). The manual work around to get the correct dwg output I always open the export options and close it. This ensure the correct output except for the text in scaled blocks. This is what I want to automate.

I looked in several dwg-export macros and found no solution.

If I follow You correctly Your suggetion is about setting up a drawing sheet with a certain scale.

What am I missing?

Johnny

Reply to
Johnny Geling remove: _removethis_

You can use something like this: vShtProps = swSheet.GetProperties dScale1 = vShtProps(2) dScale2 = vShtProps(3) swApp.SetUserPreferenceIntegerValue swDxfOutputNoScale, 1 swApp.SetUserPreferenceDoubleValue swDxfOutputScaleFactor, (dScale2/dScale1) before saving the model as a DWG.

Reply to
fatalerror64

(dScale2/dScale1) hey, an anonymous poster who knows undocumented preferences ! swDxfOutputNoScale is not even in apihelp.chm 2003. SP3.1 ! is it you, Trevor ?

Philippe Guglielmetti -

formatting link

Reply to
Philippe Guglielmetti

it exist and is written in the swconst file.

Johnny

Reply to
Johnny Geling remove: _removethis_

Sure, otherwise it wouldn't work ;-) Although it is easy to guess how to use it once you know it is there, I wondered why someone knewing this would keep anonymity. "fatalerror" would be a funny nickname for a SW insider ;-)

Philippe Guglielmetti -

formatting link

Reply to
Philippe Guglielmetti

Agreed, I was on the wrong track. I just noticed the post from fatalerror64 and agree with him/her.

There are settings in swconst.bas for setting almost, if not all options for all SaveAs formats. The trick is learning how to use them.

Have a look at the SWX API site

formatting link

************************************ Also ref to site, although for VB the file referred to is swconst.bas
formatting link
Section 9 - Solidworks Flavors Solidworks flavoring is controlled by setting various user preference values in the form "swApp.SetUserPreferenceToggle #,'value'" or "swApp.SetUserPreferenceIntegerValue #,'value'" Where # is the corresponding number of the preference parameter as defined in the Solidworks swconst.h file. Value is a value to which the preference parameter can be set. ************************************

-- Tony O'Hara Melbourne, Australia.

Reply to
Tony O'Hara

take a look at the : swxJRNL.swj file in your solidworks directory it logs in code what are doing in solidworks, for me this helps quite a lot to automate things if you don't know were to look in the api.

let me know if this helped. regards,

niek maarse technical engineer Saint-Gobain Abrasives

Reply to
Niek Maarse

Actually, I stumbled across this in swconst.bas while working on a project for one of my customers. While my handle surely fits SW at times, it was not by design. I just like keeping myself in the dark...

Reply to
fatalerror64

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.