Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Solidworks Design Table

Status
Not open for further replies.

dsheets05

Mechanical
Feb 1, 2009
22
Hello all,

I am looking for some help creating macros in excel/solid works. Let me give you a brief explanation of the project I was assigned, and what I am trying to do. One of our major product lines for the company I work for is machined plastic rings. We currently have ~1,000 different styles, with endless configurations in each style. The dimensions of the ring are based of equations. In most cases I will be imputing a cross section and I.D. dimension, which will drive the equations to create the ring. I just finished drawing all ~1,200 rings in solid works, and linked them to appreciate equations in excel. This is working great, however I was asked to create a button/macro in excel that will do the following.

Open/Save/Close the model and drawing, the model and drawing should be saved as the part number which is derived from the dimension of the part and is located in the cell label part number in excel. I created a example ring, for reference(See attached excel /solid works file). And to make it even more difficult, I need to destroy the link to the design table when it saves each part. Any help I could get would be greatly appreciated!

Thanks you,

David S.
 
Replies continue below

Recommended for you

Why destroy the link to the spreadsheet, just do not save the changes.

--
Hardie "Crashj" Johnson
SW 2010 SP 2.1
HP Pavillion Elite HPE

 
When you save the drawing it still links back to the excel file. The excel file will be continuously changing throughout the day as the designers make 100s of drawings a day, this could become a problem

.
 
Thanks for the response. I am now working with another engineer in my department on this. We decided it would be more beneficial if we wrote a macro for solidworks to make the drawings for us., so the everything would be scaled properly. He is working on linking our excel dimensions to a solidworks, by focing the dimensions from an excel document to a solidworks design tabel. And I am working on creating the drawing templates themselves. I have found various code on the internet, and compiled peices togther to create the code below. Let me tell you where I am stuck. I want the cross sectioned view to be twice as big as it is currently, so a custom sacle of 2:1. In addition, i want to import annotations(Design Annotations). However when I use the record macro function in solidworks, it does not reconize me doing this. Do you know the commands to...
1. change the scale of a view in a drawing. ?
2. turn on import annotations(design annotations)?


Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc

sOutputFolder = Left(swModel.GetPathName(), Len(swModel.GetPathName()) - Len(swModel.GetTitle()) - 7)

vConfs = swModel.GetConfigurationNames()

For i = 0 To UBound(vConfs)

Set swDraw = swApp.NewDocument(sDrTemplate, 0, 0, 0)

Dim swDrawModel As SldWorks.ModelDoc2

Set swDrawModel = swDraw

swDraw.InsertModelInPredefinedView swModel.GetPathName()

Set swView = swDraw.GetFirstView

While Not swView Is Nothing

swView.ReferencedConfiguration = vConfs(i)

Set swView = swView.GetNextView

Wend

swDrawModel.ForceRebuild3 False

swDraw.InsertModelAnnotations3 swImportModelItemsSource_e.swImportModelItemsFromEntireModel, 32776, False, True, False, False

Set Part = swApp.ActiveDoc
boolstatus = Part.ActivateView("Drawing View4")
boolstatus = Part.ActivateView("Drawing View5")
Dim skSegment As Object
Set skSegment = Part.SketchManager.CreateLine(0#, 0.03128, 0#, 0#, 0.05127, 0#)


Dim myView As Object
Dim excludedComponents As Variant
Set myView = Part.CreateSectionViewAt5(0.2062697090198, 0.1044204373142, 0, "B", 20, (excludedComponents), 0)
boolstatus = Part.ActivateView("Drawing View7")
Part.ClearSelection2 True
swDrawModel.Extension.SaveAs sOutputFolder + swModel.GetTitle() + "_" + vConfs(i) + ".slddrw", swSaveAsVersion_e.swSaveAsCurrentVersion, swSaveAsOptions_e.swSaveAsOptions_Silent, Nothing, 0, 0

swApp.CloseDoc swDrawModel.GetTitle()

Next

End Sub

Thanks again,

dAVID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor