Macro Excel

Hi all.

 

I will try to be clear.

 

- I have a sheet metal profile that I need to export in dxf (unfolded sound)

- This profile varies in length

- I have the list of all lengths in an Excel workbook as well as their respective quantity.

 

Is it possible via the excel file, to export all the dxf according to the lengths, automatically.

A little extra point, between each change of lengths, we must have a triple reconstruction because there are formulas to recalculate according to the length.

And also, if possible, have in the name of the dxf, the quantity relating to such and such lengths.

 

Do you have to go through a family of rooms? By a macro? Or something else?

 

I think it's understandable =)

 

 

 

2 Likes

Here's a glimpse of what I'd like in the end.

 

From the excel, arrive at a list of dxf file.

 

Thank you! =)


exemple.png
1 Like

Hi Bart,

We will need a little more. How does your SW file work? Several configs or only one and we change the length?

Personally I would make a SW file with a family of parts. So we would have a configuration by length.

Then in the code:

  1. Open the file
  2. Browse each config in
    1. Selecting a config
    2. Reconstructed
    3. Export in dxf (How do you want to manage the dxf file?)
    4. Move on to the next one if it exists.
  3. Saves the SW file

Did I understand everything? Is that suitable?

2 Likes

Yes @remrem, basically that's it.

 

I have an excel file with for example 500 different lengths.

My part has holes spread over the length.

 

Therefore:

  1. I place the Excel file with the document in the customer file.
  2. I throw a macro,
  3. Sw unfolds my piece for the first length,
  4. Exported in DXF to the client file
  5. Sw includes (or not) the quantity that is in excel in the name of the dxf
  6. Then it goes to the next line
  7. rebuilt 3 times
  8. then do the same trick again, export in dxf etc....

If I summarize, I start from a room with its excel and end up with a list of dxf by lengths.

 

1 Like

I'm going to repeat myself but your play has a family of plays or not?

Then how do you know which configs to taritate: what does your Excel file contain the name of the config, the length? Is there a relationship between the length and the name of the config?

Here's an example of a macro that lists the configurations of a file: http://help.solidworks.com/2015/english/api/sldworksapi/Get_List_Of_Configurations_Example_VB.htm

Then you will have to compare the list obtained with the one in your Excel file.

Then export to dxf: http://help.solidworks.com/2015/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.ipartdoc~exportflatpatternview.html

 

2 Likes

At first glance, it doesn't seem impossible to me. I don't know the gateway to go from excel to part opening in solidworks ... But I don't see why it couldn't be done.

 

To forgive, then. When you've solved @Bart, if you could give us the outline of your code. It could help in the future;)

2 Likes

I attached an image in my first post.

 

You can see the stages of my approach.

 

At the moment, I have a part that has equations driving functions.

No part family or configuration.

My Excel contains the name of the part, its length and its quantity (at worst for the qty, I manage)

 

I know it's possible, but the question is how?...

Then if I have to go through a macro, I'm a .... in VBA :/

http://www.lynkoa.com/forum/3d/mise-jour-auto-famille-piece

 

I read in zigzag, but apparently he managed to make a join in SolidWorks and Excel.

2 Likes

I understood your approach.

But I want to know if you can adapt your room to make the macro easier to achieve or if the macro should completely adapt to your environment.

Personally, from experience to achieve this kind of thing and that it works perfectly. It takes quite a bit of time. That's why it's necessary to put things right and to determine our goal clearly. Because otherwise you find yourself coding and then starting all over again because it doesn't suit anymore.

Without mastery of the VBA. I advise you to break down your project according to it and carry them out one after the other. Ex: Opening the file, list of configs, export. And to ask, try and then ask questions on the forum.

For me, I can't carry out this project completely. The goal is also to learn, because if you are given all your codes you will be unable to make them live in time.

Good code :-)

3 Likes

I completely agree with you Remrem.

 

That's why I've detailed everything step by step.

 

I'm not asking for a turnkey macro, but more to know where I should go.

If I have to go and see the parts families or not, if a macro is necessary etc etc...

 

I've laid things down, all that's left to do is code step by step

1 Like

So I'm going to start on my own, and I'll ask questions when I get stuck.

 

That is to say soon! :p

4 Likes

@KVuilleumier:

A relationship between Excel and Sw is quite possible.

Personally, I created an application that integrates with excel and SW driver: modification of properties, export of nomenclature...

But once again Bart has to tell us what he wants to do: Control SW from Excel OR then SW read his Excel file and process the info...

Personally, I would lean more towards the second.

 

2 Likes

Hi all

I think it will be easier to create your part family from your Excel file before  (link below):  it will take you 1 or 2 minutes, while the program can be difficult to make and will be a source of errors.

http://help.solidworks.com/2013/french/SolidWorks/sldworks/t_Inserting_an_External_File_as_a_Design_Table.htm

Then you just have to insert this macro which creates the DXF for all configurations:

 https://forum.solidworks.com/thread/27842

This video may also be interesting:

https://www.youtube.com/watch?v=8SW-UZy1QMA

Edit: see also:

https://www.youtube.com/watch?v=rSeYL77cqBQ

 

2 Likes

Just like PL, I think the part family would be a good thing. And above all, it would allow you to keep the maximum amount of information and functions in your SW files. That is to say that if your code no longer works or a user does not have access to it, a large part of the information is accessible in SW.

Looking forward to helping you...

:-)

2 Likes

The cool thing about making a macro program is that it can copy its native file into the client's specific folder, open its excel and control everything.

 

Whereas with the family of parts, he will be forced to create a new one for each customer (if I understood how it works)

1 Like

@coin37coin yes but spending 1 day programming (maybe less for an experienced VBA user, but I don't think that's the case for Bart) retrieving odds in an Excel file, is it worth it? And assuming that the Excel file still has exactly the same formatting, otherwise it crashes!

If the creation of the part family takes a maximum of 5 minutes (and I think it's less than 5 minutes) to do in SolidWorks by hand, then you would have to do at least 80 minutes for it to be profitable on a 7-hour day...

2 Likes

Surely... It's the dark side of the story

1 Like

That's the thing,
It's that I receive an Excel from the client, but I'd like to avoid retyping everything.

 

This is a source of error. I'll have to go through Solidworks and throw a macro for it to grind and get my list of dxf files in the client's folder.

 

In my case, the Excel file will always be the same, it will always be the length that will change and while we're at it the length of the wings.

 

And by going through Driveworks? I can't get everything back at once?

 

I want to spend 1 day programming, it's something that comes up often, so it will still save me time.

1 Like

Well I'm arriving a bit like that, without having read the whole conversation, so mea culpa if it's already been discussed but:

When you receive the Excel file from the client, it is always formatted in the same way?

For us, we proceed with a "construction sheet", it is an excel file where the technical sales representatives enter all the sizing information but also other information for other departments of the company.

Then the B.E uses a sheet called the "Recap'", it is a sheet with a macro that opens this construction sheet, which copies the essential information for the design office and pastes it in certain boxes. It is this sheet that is related to our CAD.

Here I have just told my life:)

2 Likes

@Aurelien (from Axemble support) :p

 

I get different excels, but formatting them only takes me 2 minutes.

Sorting an Excel is faster than typing everything in Sw by hand, then exporting everything one by one in dxf =)