Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Creating Custom Task API Stuff

Status
Not open for further replies.

Russell67

Automotive
Nov 1, 2005
114
How can i go about creating a custom task to do the following

1.Open an assembly
2.Get all referenced files, down to the sub of the subassembly level
3.Check and see if those files have a drawing
4.Convert to PDF or print.

Unfortunatly for me i am not familiar with API and macro stuff and unfortunatly the place i work see's this as a waste of time, but it is okay for me to spend 8 hours locating and printing the package to only forget stuff. So for me to create this on my own would require me to do it at home, were a copy of solidworks does not exist.

I am not asking anyone to do the work for me, but assist me in the understaning of creating this task. Thanks in advance.
 
Replies continue below

Recommended for you

I have some questions:

1) Do you have a PDM system?
2) What do your folder structure and filenames look like? Is the filename relevant to the folder location, or are the filenames totally independent of location?
3) For any model, is the associated drawing to that model stored in the same folder as the model?
4) Do you want to convert to PDF or print, or both (different ways to do each)?
 
1. No PDM system, single man shop
2. Folder structure is set-up on the network. If it is for a customer there is a folder listed "CUSTOMER" and subs for the customer and then subs for the projects.

3. I can only hope that the model and the drawing are in the same directory. Previous employees were learning 3d modeling so finding little birdies here and there.

4. Prefer both

Another is that i like using configurations of parts. When i do this the part is in the original directory but the drawing is in the new designs folder. I can live with chasing down a drawing or two, but for some of these projects the parts could span 4 or 5 folders.

 
I have uploaded some sample macros into a zip file at the below location:


The macros are either copied directly or based on sample macros that Lenny Kikstra has on his website
AssemblyBOM.swp traverses an assembly and generates multiple types of BOMs.

AssemblyLevelMacro.swp traverses an assembly an looks one level down at all of the parts and searches for a custom property called "level" if it finds level in all of the lower level parts, it will create a "level" custom property in the assembly and assign a value one digit higher than the highest value in the subcomponents. It then saves a copy of the assembly into a folder named "Level x".

CopyChildrenDrawings.swp traverses a current working directory and for each file selected goes out to a path (that is hard coded in the macro) to find a drawing (.slddrw) that has the same name as the part. In my case a unique 7 digit number.

PrintDrawings.swp traverses a current directory and prints each file selected with whatever printer was last used within solidworks.

Using these macros, you should be able to build your own to do what you need based on your company's naming conventions etc. Also check out Lenny's site for other macros that may help as well.

I am indebted to Lenny Kikstra and handleman for their help while I was hacking together the code that I needed to perform the tasks I needed. You are in the right place to find the help you seek.

-Shaggy
 
I like the AssemblyBom.swp macro. This does just what i need, however instead of EXT for the <DIR> i would like the path for that part. Another fact is that i just don't spend alot of time using or writing macros so alot of this is greek to me. Is there an easy switch that i can do to that macro to get what i need? Thanks
 
We need some more info to be able to tell if this problem can be solved with a macro. It really depends on your file management and file naming practices. The possible scenarios are:

1) For the cases in which the drawings you need to print are all in one folder (or a small number of folders) you don't need a custom macro. Use "Print Drawings" from the SWX task scheduler to do the job.

2)For drawings that are named in a consistent manner with respect to the parts/assemblies that they refer to and are located in either the same folder or in a folder that is related in a consistent manner to the folder of the part - a custom macro can be easily done to loop through the dependant documents of the main assembly, find the drawings and print them out. You will have to explain how your folder structure and file naming works in order for us to help you.

3) If your drawings are randomly spread throughout the network or are not consistenly named then you are SOL and need to get more strict about file management. Yes it is possible to manually search everywhere for drawings that refer to each part but I can guarantee you that it will very likely take even longer than browsing in Windows Explorer. There needs to be a logical way for the code to find the drawing for each document referenced by the parent assembly.
 
Well the file system here is hosed. Alot of wht i need this for is legacy stuff that prior hackes created. All the files tend to be located in a small group of folders. I tried to work this through task scheduler, but i spend time in explorer looking for the file then finding it via task scheduler then running the task.

In an effort to help my cause i have created a macro from within Excel that looks for a drawing of a part from a bom
refer to thread


If if knew how to delete threads this would be gone, cause i realize that i need to be proactive and get help when i stumble. If there is anything in there that i can get some help with that is greatly appreciaetd. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor