API help

While in a drawing, I need to write (at the push of a macro button) in a text file the document name and the current sheet name. And if possible print the current sheet (only).

Anyone could get me started?

TIA JM

Reply to
Jean Marc
Loading thread data ...

No, I can't.

Writing the document name to a filie is no problem. (For a log file, right?)

Printing in VB is tricky. However, it can be greatly simplified if you fix the printer name, sheet size, etc.

Reply to
That70sTick

"That70sTick" a écrit dans le message de news: snipped-for-privacy@f14g2000cwb.googlegroups.com...

The writing in the text file is the main (and mandatory) part. Yes, it's kind of a log file for following up the making of the part (prototype) in our shop.

I would use the default or current settings.

Thanks JM

Reply to
Jean Marc

Hi,

You want to have a look at the sources to swBatchPrint available at swCP3.com?

Would that be of any help?

With regards,

Vinodh Kumar M.

formatting link

Reply to
GreenHex

To Print

Part.PrintDirect 'will send all sheets look up Part.PrintOut2 ' this will allow you to specify a printer specific pages to print and other settings

this will get you really close

'you must reference "Microsoft Scripting Runtime" 'Tools>References then select "Microsoft Scripting Runtime" from the list

Dim swApp As SldWorks.SldWorks Dim Model As SldWorks.ModelDoc2 Dim Drawing As SldWorks.DrawingDoc Dim PgSetup As SldWorks.PageSetup

'this is the path to the log file change it to whatever you desire. Const LogFileLocation = "C:\PrintLog.txt"

Sub main()

Dim FS As New FileSystemObject Dim Log As TextStream

Set swApp = Application.SldWorks Set Model = swApp.ActiveDoc Set PgSetup = Model.PageSetup

'connect to log file if it doesn't exist it will create it automatically Set Log = FS.OpenTextFile(LogFileLocation, ForAppending, create:=True)

'write the date and time and the file path to the file Log.WriteLine Format(Now, "MM/DD/YYYY HH:MM AMPM") & _ " " & Chr(34) & Model.GetPathName & Chr(34)

'close the file Log.Close

'Print the entire document (all sheets) Model.PrintDirect

End Sub

Reply to
CS

Thanks a bunch, that will help me a lot.

JM

"CS" a écrit dans le message de news: snipped-for-privacy@g43g2000cwa.googlegroups.com...

Reply to
Jean Marc

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.