Solidworks macro question
Solidworks macro question
(OP)
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
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






RE: Solidworks macro question
RE: Solidworks macro question
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
RE: Solidworks macro question
Hope this is helpful,
Brenda
RE: Solidworks macro question
Hope this helps.
RE: Solidworks macro question
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.
RE: Solidworks macro question
Thanks
RE: Solidworks macro question
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