Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Solidworks macro question

Status
Not open for further replies.

blinncqui

Electrical
Sep 30, 2003
8
CA
I recently developped a macro that changes all the customs properties of Solidworks drawings for a specified project. That way people don't need to do it by hand when the drawings are re-use for another project number and customer. So what the macro does is change the info for customer, project number date etc... for a the parts and assembly's of a project.

I would like to push the thing a litle further and do it also with drawings (.slddrw). My problem is that all the custom info used in the the drawings are linked to the file use to create the drawing ( a part or assembly ) in the view, is there a function or a way that I could modify that link from the drawing window to the new drawings so that way it will use the properties of that drawing and not the old one ?

Thanks for any input of coment on the subject
 
Replies continue below

Recommended for you

In your first paragraph you say your macro changes drawings. Do you mean models? If the drawings custom info is linked with the model or assembly custom info, it should automatically update when you change the model. Please clarify what you are trying to do.
 
Hi Regg,

thanks for answering... Yes I agree with you when you open and update the drawing , it will take the values of the properties of the Assembly. But the thing is that if I take for example the assembly 22118-01.sldasm and save it under the new name 23118-01.sldasm the new custom properties are in the new drawing but when I try to do the same with a drawing, well the drawing takes the values of the custom properties of the old one, wich is the 22118-01.sldasm. So my question was if there is any function that I can use in a macro to tell the drawing "this is the new source for you( in this case it would be 23118-01.sldasm )". I know it may be impossible without a person having to do it manually but it would be a time savior...

Anyway thanks for any help and if you need more ino i will try to get it to you.

Thanks
 
I wrote a sample macro that accesses the model referenced by a drawing and its custom properties. If you want to take a look at it, it might be helpful in seeing how to get access to the model, etc. It's on my webpage, go to the bottom of the main page where it says "Presentation to Madison SW User Group 01/09/03". This takes you to a powerpoint on custom properties--the slide you are interested in with a link to the macro is called "Vrooman macro for PDMWorks". (It's purpose is to read in properties from the model and write them to the drawing. It was inspired by one of the user group members who wanted to have properties in the drawing doc itself to interface with PDMWorks.)

Hope this is helpful,
Brenda
 
In SolidWorks go to open, click on 22118-01.slddrw, click on references, double click on the file shown, go to 23118-01.sldasm, click open, click ok, click open. The drawing will open pointing to 23118-01.sldasm. Go to File, Save As.., save it as 23118-01.slddrw. Now you have two drawings 22118-01.slddrw referencing 22118-01.sldasm and 23118-01.slddrw referencing 23118-01.sldasm.

Hope this helps.
 
Hi,

To me it sounds like you're best off using SolidWorks Explorer to make a new copy version of your SW files. I get the distinct impression that you're getting crossed-up with how to manage file references in SW and really don't need a macro to do what you want to do.

Really I believe that you will best served by doing the following (using the example you've already given):

1. Copy the files (22118-01.sldasm, its associated components, and the drawing) that you want to use in a new Project to a new folder.

2. Open the SW Explorer utility.

3. In SW Explorer,

- Click on the File menu

- Select Open from the menu

- Navigate to the location of the copied files

- Select a file to rename/update *

- Click on Open in the dialog box

- RMB on the file to rename in list

- Select Rename

- Enter a new name in the space provided

- Click on Find Now **

- Review the list of referenced files ***

- Adjust the update property as required

- Click Apply

- The file is renamed and references are updated

- Repeat the process as required

* TIP – If a part/assembly file has an associated drawing, I find it best to select the drawing as any file associations between it and its parent part/assembly are automatically displayed in a Parent/Child fashion when opened in SolidWorks Explorer. This minimizes the task of navigating to each individual file as outlined above.

** This searches for any files referenced by the file being renamed and is also known as a “Where Used” search – see the SolidWorks Explorer help file for more information

*** There may not be anything referenced by the currently selected SW file

I believe that this process will give you exactly what you're trying to do with core SW functionality (i.e. no macro required).

Chris Gervais
Sr. Mechanical Designer
Lytron Corp.
 
First of all I wan't to thank everyone, I am going to explore every possibility that was mension here and will let you know next week how I fixed the problem . If anyone as any more suggestion let me know I will try them all

Thanks
 
I did it,

i was able to change the reference in a drawing with a simple macro by using 2 API function :

GetDocumentDependencies2
ReplaceReferencedDocument

Those two functions allow me to get the present reference and change it to the appropriate new one. I found those functions by looking up some information from
CSOLIDS. So a big thanks to her and thanks to everyone who gave an input on the subject

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top