×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

batch process format swap

batch process format swap

batch process format swap

(OP)
Hi All
Been experimenting with the attached macro with success. Trying to add functionality and are loking for help from the more knowlegible. The macro swaps a drawing format to another specified in the macro.
I would like to automate and have it:

detect existing format and sheet size
swap out to modified format-same size
kepp all notes i sheet format(added manualy at creation of drawing)
keep notes in drawing, idealy same relative position if possible
all in batch process-files form specified folder

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swDraw As SldWorks.DrawingDoc

Dim i As Long

Dim bRet As Boolean

Dim vSheetName As Variant

Dim swSheet As SldWorks.Sheet


Sub Main()


Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

Set swDraw = swModel


vSheetName = swDraw.GetSheetNames

For i = 0 To UBound(vSheetName)

bRet = swDraw.ActivateSheet(vSheetName(i))


'Put any sheet format name

swDraw.SetupSheet4 vSheetName(i), swDwgPaperCsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\C-Size.slddrt", 0#, 0#, "Default"


'Put the required sheet format name

swDraw.SetupSheet4 vSheetName(i), swDwgPaperDsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\D-Size.slddrt", 0#, 0#, "Default"

swModel.ViewZoomtofit2


Next i


' Switch back to first sheet and change format

bRet = swDraw.ActivateSheet(vSheetName(0))


'Put the required sheet format name

swDraw.SetupSheet4 vSheetName(0), swDwgPaperDsize, 12, 1, 1, False, "C:\Users\Desktop\CreateFolder\Formats\D-Size.slddrt", 0#, 0#, "Default"


swModel.ForceRebuild3 (False)

swModel.Save


End Sub

RE: batch process format swap

On the surface, that should almost all be possible.

The tricky thing is the notes that you've added to the current sheet format during drawing creation. I'm sure that the sheet format had some notes in it already when the drawing was created. Those notes (I assume) do not go over to the new sheet format. Only the "extra" ones that were added during drawing creation. How would the macro know which notes were the ones that need to go over? The only thing I can think of is that you would have to create a fresh, new "dummy" sheet using the old sheet format. Then the macro would have to compare content of each note of the sheet you want to transfer with the "dummy" sheet and only transfer notes that don't appear on the "dummy" sheet.

The rest of the tasks are relatively straightforward, it'll just take some time to write. If time is something you have less of, I can make a good recommendation on a hired API gun or two.

-handleman, CSWP (The new, easy test)

RE: batch process format swap

(OP)
Thaks SBaugh, scheduled for next session
handlean- hoping to crete new sheet format with notes addition in part properties.
This format would be available for new projects. Exsting I agree would pose prob;ems. Thanks

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources