Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

Macro for Beam Profile Generation 5

Status
Not open for further replies.

kgwhipp

Mechanical
Dec 6, 2010
33
thread559-179657

I did the best I could to search and find a macro to work with but a lot of the links/files are old and/or no longer work with SW.

I'm running SW 2010 3.1 and I've created a few .SLDLFP parts that consist only of a single sketch that represents a profile of extruded metal beams. The sketch is driven by an extensive design table (100 or so configurations).

The problem: I want to save these profiles so that I can choose them from my weldments profile list. The only way to do that right now is to pick a configuration, save-as SLDLFP, and rename the part (from "BeamProfile" to the profile name: "40 x 25 x 1.5".).

I'm sure this will be helpful for anyone that finds the in-built GB standards lacking, so maybe I can barter these files for some macro mastery help?

Thanks in advance from a Macro Newbie,

-KG


-Kevin
 
Replies continue below

Recommended for you

Thanks Shaggy but I've already installed these and they don't match what our overseas steel provider has given.



-Kevin
 
There is a macro out there that will save each configuration as its own part file. That will get you part of the way there. Do you know if you need to do a "save as" on the .sldprt file to change it to a .sldlfp? Can you simply change the file extension in windows explorer?

-Dustin
Professional Engineer
Pretty good with SolidWorks
 
Awesome find! Thanks Shaggy. The config ripper saves the files as .sldprt files.

There's a lot of code inside that deletes the other configs that doesn't seem to work anymore, but that's OK.

I tried changing the file extension in windows but apparently solidworks adds a tag within the file when it's a "library feature" because it didn't work when I tried to open.

Now I just need to figure out how to add the code to make it save as a different file.

I think this might be where I need to add/modify the SaveAs prompt to saveas a SLDLFP type.

/code: (I don't know how to make this register as code, any formatting tips?)

For i = 0 To UBound(ConfigNamesArray)
ConfigName = ConfigNamesArray(i) 'Assign next config name to ConfigName variable
Part.ShowConfiguration2 (ConfigName) 'Set next config as current
NewName = Location & ConfigName & ".sldprt" 'Create path
Part.SaveAsSilent NewName, True 'Save as current config name
Next i



-Kevin
 
Admittedly I am a hack when it comes to macros.

Try changing the below code:

Code:
NewName = Location & ConfigName & ".sld[red]lfp[/red]" 'Create path

Its worth a shot

-Dustin
Professional Engineer
Pretty good with SolidWorks
 
And do add the codes for selecting the sketch too before it is saved as library feature file.

Code:
boolstatus = Part.Extension.SelectByID2("Put the sketch name here", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
   
NewName = Location & ConfigName & ".SLDLFP" 'Create path

Deepak Gupta
SW 2010 SP4.0 & 2011 SP1.0
DriveWorks Pro 7 SP5
Boxer's SolidWorks™ Blog
 
Add the following before you save the file:
Code:
swDoc.AddCustomInfo2 "Description", swCustomInfoText, ""
swDoc.CustomInfo("Description") = "Text visible in Cut list table"
this will change the setting in your original file but its not important, the current text will go into the file saved (I hope)

Without this property set you will get the same text for all Profiles in your Cut List Table.
 
You guys rock!

I'll have a chance monday to try these out and see how it goes.

I'll upload the final script and profiles once I get it all going!

-Kevin
 
Have been trying to do similar. Create a weldment library from a part file with multiple configs.
I am no programmer and after trial and error (many of them) I put together this solution that works for me on SW2011 SP4. X64Bit.
First download a copy of ConfigRipper...
1) Open weldment part file that has multiple configs.
This file should have only a sketch, no solid features.
2) Saveas Library file *.sldlfp
3) Select sketch (note name) Right Mouse Click, Select "Add to Library"
4)Save
5)Edit ConfigRipper
5.1) Change all "sldprt" to "sldlfp"
5.2) Rem (')'If Part.GetType <> swDocPART...... down to....
'Else
' GoTo Rip
'End If
(This is because we are now opening a sldlfp file not a part file)
5.3) add the following from Deepak after NewName+Location....
boolstatus = Part.Extension.SelectByID2("Pipe", "SKETCH", 0, 0, 0, False, 0, Nothing, 0) ' Thanks to Deepak Gupta
and just before... Part.SaveAsSilent NewName,....

5.4) Replace the sketch name "Pipe" with the sketch name in your file

6) Save macro

7) Open Library file
8) selct skectch (just in case)
9) Run new macro.

I Suggest you try it with just 3 or 4 configs first.
Have the file in its own empty directory.
When done copy new file to yur weldment direct in new folder and test.

I ran this on a file with 275 pipe sizes, too approx 1 hour.

Thanks to all for posting and sharing the bits and pieces, hopefully this helps speed up the process for the next person.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor