Perform a function import/recognition diagnostic on a batch of files

Hi all 

I regularly import files (types of assemblies and parts) from suppliers and before working with them, I first carry out an import diagnosis and sometimes recognition of the functions. Nevertheless, I find it tedious to do it for each "file" of an assembly (see attached files). Is there a way to do this faster and thus perform this task for a batch of files? 

Thank you for your help


diagnostic_reconnaissance_fonctions_batch_fichiers.png

If you have a Premium version, maybe with the Task Scheduler.

Alternatively, you can save the asm as a prt and then run the diag (if you don't absolutely need to keep the asm).

Hello StefBeno, 

I think I have the right license to do this kind of thing. Any idea of the procedure/procedure to follow to do this? 

 

Thank you

Unfortunately no, I don't have a premium license...

Hello 

first insert the import task, (the file will save or the original file is.

And in my opinion for the import diagnosis, its must be in the custom tasks, you have to make a macro for that, but I don't know the command. 

 

Kind regards


capture.jpg

Hello

If, in addition to the task scheduler, you have to make a macro, then it may not be worth bothering with this one... Your need is quite achievable by macro, of course it depends on your degree of knowledge on the subject. The following is a list of functions to use to analyze an assembly and perform import diagnostics and feature recognition for each child element:

Opening of the ASM then:
- ActiveDoc (ISldworks)
- GetRootComponent3 (IConfiguration)
- GetChildren (IComponent)
- GetModelDoc2 (IComponent)
- OpenDoc6 (ISldworks)
- ImportDiagnosis (IPartDoc)
- CallBack("fworks@FWPlaybackManager", 0, "...... ") (ISldworks)
- SaveAs (IModelDocExtension)
- CloseDoc (ISldworks)
Then we loop on the next element to the last child.
Don't forget to save the ASM at the end of the treatment.

It can make a pretty nice macro and that would surely be very useful to many users ...

Kind regards

Hello d.roger,

I am revisiting the subject. I have the same problem as charleslr.

I find the function recognition step long and tedious when it comes to a complex assembly. Using a macro seems to me to be the best solution.

Not really knowing the VBA language, would it be possible to have a macro capable of executing this function?

I tried to record the macro with the above functions but I don't have the time or the skills to do it.

I'm on SW 2019 STD.

Thank you

Sincerely, Thomas

Hello 

If I have time soon, I can possibly get started on the subject. I'll add a few more functions, including the choice of assembly export (personally I export assemblies in .sldprt in order to lighten my designs).

Charles

Here is an answer: 

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

Hello charleslr,

Thank you very much for these answers.

Personally, I don't need to register my assemblies in .sldprt because I need this design for the realization of the parts in the workshop.

In Ulf's macro, I block at the level of:

longstatus = Part.ImportDiagnosis(True, False, False, 0):  ( property or method not supported by this object).

Any leads?

Thomas.

Hello

Yes for a track: the "ImportDiagnosis" function only works on parts, not on assemblies.

Kind regards

Sorry I'm not going to have time to watch this right now. I'll try to dive into it in February.

Cdtl

Hello d.roger,

Thank you for the answer,

In this case, how do you tell him to do the reconnaissance for each part of an assembly and loop on the next?

Maybe you should first try to have a code that works on a part and then we'll see for the rest for an assembly?

You will then have to be careful in the event that your assembly is made up of the same part several times. I will read the architecture of the assembly, when I see a new file name I put the file name in a list, then once finished I perform the import diagnosis on the files in the list. Maybe there are simpler things, but I'm a mechanic, not a computer scientist :-).

1 Like

All the necessary functions are already given in a previous message, as a reminder:

The following is a list of functions to use to analyze an assembly and perform import diagnostics and feature recognition for each child element:

Opening of the ASM then:
- ActiveDoc (ISldworks)
- GetRootComponent3 (IConfiguration)
- GetChildren (IComponent)
- GetModelDoc2 (IComponent)
- OpenDoc6 (ISldworks)
- ImportDiagnosis (IPartDoc)
- CallBack("fworks@FWPlaybackManager", 0, "...... ") (ISldworks)
- SaveAs (IModelDocExtension)
- CloseDoc (ISldworks)
Then we loop on the next element to the last child.
Don't forget to save the ASM at the end of the treatment.

Kind regards

1 Like

Thank you d.roger for the reminder of the previous message. I did, however, look for a lead by reading this post before asking myself these questions.

@charleslr, ok for February, let me know if you have any new elements, I'll also run out of time until the end of March.

Thank you, gentlemen, for your contributions.

Kind regards

Hello 

An old subject but one on which I have made progress in recent weeks.
The principle of my macro is as follows: 

Look at the input file extension (SLDASM, SLDPRT, STP, X_T, ...)  and by various means saved it in . SLDPRT and close the template file. Then he will carry out an import diagnosis on the saved part, repair the defective faces, block the part and save this new part. 
Attached is the macro in VBA.

I let you modify it as you wish and or improve it as needed. Feel free to post your future revisions!

 

 


import_diag_12-07-2021_1.swp
1 Like