Solidworks Control Sheet

Hello

I am trying to recover the drawing dimensions in order to replace them in an exel sheet, and in a drawing table

The end goal is to create a control sheet for the parts

I guess that my leaves are different every time.

The best thing to do is to reference the odds ;)

I'm stuck on the repatriation of the odds on Exel

..

Here is attached a beginning of code that can be useful

 


anotation_plan_solidworks.txt

Hello

In your macro, you open Excel but you don't send it anything. You also have to create a binder, a sheet and fill in the cells. The debug.prints are only used to display the result in the VB output window. Here is the same macro but with a result that is displayed in excel.

Kind regards


anotation_plan_solidworks-2.txt
2 Likes

the extraction this pass nikel thank you

, do you have a solution to add a note on the drawing to reference the dimension in the table and the drawing, in a clearer way

1 Like

Hello

For example, you can add a text at the bottom of the call number if it is not already in use. To try, you can add the line swDispDim.SetText swDimensionTextCalloutBelow, "(Ref A" & counter & ")" just before the line . Range("A" & counter). Value = "Reference below  : " & swDispDim.GetText(swDimensionTextCalloutBelow)

Kind regards

Hello

First of all, I would like to point out that I know absolutely nothing about macro!

I dig up an old subject. I would like to make control sheets for the workshop. I found this post with a macro text. I copy paste and surprise it doesn't work. What for? if someone will give me his time to elucidate this mystery.

May the Force be with you


obiwan.swp
1 Like

Hello OBI WAN,

You need to add the reference to Microsoft Excel in your macro, for this you go to Tools / References... and you add Microsoft Excel xx.x Object Library:

Kind regards

3 Likes

Hello @d.roger

Thank you for your intervention and especially for your efficiency.

may the force be with you.

 

1 Like

Hello,@d.roger

With your help I have made good progress on the subject of control sheets. but I would like to go even further with the macro. I explain when executing the macro it opens any excel file but is it possible to make it open a pre-filled excel file that would contain a macro.

may the force be with you.

 

 

FYI we can do something quite close to what you want to do with the "tolerance table" utility of MyCADTools I have the impression (creation of a table retrieving the dimensions + location of them)

1 Like

Hello OBI WAN,

Yes it's possible, you replace the lines:

Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
Dim wbk As Excel.Workbook
Dim sht As Excel.Worksheet

With xlApp
    . Visible = True
    Set wbk = . Workbooks.Add
    Set sht = wbk. ActiveSheet
End With

Through these:

Dim xlApp As Excel.Application
Dim wbk As Excel.Workbook
Dim sht As Excel.Worksheet

Set xlApp = CreateObject("Excel.application")
xlApp.Visible = True
Set wbk = xlApp.Workbooks.Open("C:\Users\XXX\Desktop\anotation_plan_solidworks-5.xlsx")
Set sht = wbk. ActiveSheet

By replacing the file name with your file of course.

Then you have to change the lines between the "With sht" and the "End With" to put your values in the right cells.

Kind regards

2 Likes

Hello

Thank you @d.Roger it works like a ton thanks to you.

I finalize and make available on Lynkoa.

Thank you again very much.

the force is with you.

 

2 Likes

@ mdelbecq  I don't have mycadtools sniff.

Hello @d.roger

Here is the macro as well as the Excel file to make the control sheet. There's just a bug if on the plan there is an angel rating there it screws up.

Otherwise it's simple on the plan in order to limit the sorting of the dimensions you have to put first only the dimensions to be checked then run the macro, on the excel file that is opened click on the button and in the second tab is the control sheet. If anyone has another idea to customize it, let go.

PS: in the macro remember to change the path to the Excel file

May the force be with you.

 

 


obi_wan.zip

Hello

So yes it works unless the dimension is an angle which is normal because in your macro on Excel you have the line "Temp = Replace(Split(Temp, "(")(1), "mm)", "")" which allows you to rework a value retrieved from the sheet created automatically from the SW macro but this value is not on the same writing format as for the other sides what we see in the lines:

If swDispDim.GetType = 3 Then
                    . Range("A" & counter). Value = "Value : " & swDimension.GetSystemValue2("") * 180 / pi & Chr(176)
                Else
                    . Range("A" & counter). Value = "Value: " & swDimension.GetSystemValue2("") * 1000 / 25.4 & """" & " (" & swDimension.GetSystemValue2("") * 1000 & "mm)"
                End If

of the SW macro.

These lines are just a formatting style of writing the dimension value for the Excel file and this can be changed easily as needed.

I have a hard time understanding why you go through a macro in your Excel file, everything you do in it can easily be done in the SW macro.

For my part, I would have tended to create a standard form in Excel and then fill it in from the SW macro, which avoids having to authorize macros in Excel and which also allows the reading of this file on LibreOffice for example.

The rows to be reworked in the SW macro are those between the "With sht" and "End With" lines to display only the values that are deemed necessary and send them to the desired Excel cells. A small example will surely follow in  the coming days (or hours) following my availability.

Kind regards

Hello

Here is the small example as previously announced. You just have to change the path of the Excel file in the macro but leaving the file name as it is and then launch it from SW with a loaded plan.

Kind regards


fichecontrole.zip
1 Like

Hello @d.roger

You're a champion, my champion. Well, as said above, I don't have any knowledge of VBA, so I tinker, I tinker.

The Macor works well but curiously I have to run it 2 times. The first time she bellows at the first odds. I close Excel, I have an error 1004 I answer "end" I restart the macro and the miracle it works perfectly.

let the force remain with you.

Hello

There are several possible reasons:

- 1 Excel process is already running.

- Successive launch of the macro too fast (Excel didn't have time to close completely).

- ...

I didn't take the time to handle the errors in the code...

Kind regards

1 Like

Thank you

One day I'll have to take the time to get started with the VBA.

may the force be with you.

 

1 Like

OBI WAN

"Otherwise it's simple on the map in order to limit the sorting of the dimensions you have to put first only the dimensions to be checked then run the macro, on the Excel file that is open click on the button and in the second tab is the control sheet. If anyone has another idea to customize it, let it go."

What do you mean by putting first?

Since I have a drawing with about 100 sides and I only want 5 sides in my control panel

Thank you