×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Creating Custom Task API Stuff

Creating Custom Task API Stuff

Creating Custom Task API Stuff

(OP)
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.

RE: Creating Custom Task API Stuff

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)?

RE: Creating Custom Task API Stuff

(OP)
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.

RE: Creating Custom Task API Stuff

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

http://www.mediafire.com/?8mtldwmzigg

The macros are either copied directly or based on sample macros that Lenny Kikstra has on his website www.lennyworks.com

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

RE: Creating Custom Task API Stuff

(OP)
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

RE: Creating Custom Task API Stuff

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.

RE: Creating Custom Task API Stuff

(OP)
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

http://www.eng-tips.com/viewthread.cfm?qid=192120&amp;page=1

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources