bart
November 16, 2015, 10:09am
1
Hi all
I come back to the charge concerning the macro mentioned in this question.
To sum up, I have an Excel file which is the customer's order on one side, and a parameterized Solidworks file on the other.
I simply want Sw to unfold each of the configs of my family of parts and export it in dxf with the name of the config.
So I downloaded the macro here.
But I am stuck on some points.
- When I launch the macro, it, by reading my part family, creates unfolded states (Flat pattern) for all my configurations. No problem, but the problem is that it also exports these configs, so I end up with duplicate parts.
- My part needs to be rebuilt 2 times for the quations to resolve correctly. So I would like that before the export of each config, Sw rebuilds the part 2 times before each dxf recording.
I think that's about it...
With that, I'd be almost at the end of my "project"
Thank you =)
1 Like
bart
November 16, 2015, 10:13am
2
Additional info for those who don't know, I have no knowledge of Vba ^^
I attached the screen print of the basic macro
macro_de_base.png
remrem
November 16, 2015, 10:21am
3
For the reconstruction of the parts:
Uses the method: Part.ForceRebuild3
Example here: http://help.solidworks.com/2015/english/api/sldworksapi/rebuild_example_vb.htm
and here (for all configurations): http://help.solidworks.com/2015/english/api/sldworksapi/Forcibly_Rebuild_All_Configurations_Example_VB.htm
2 Likes
bart
November 16, 2015, 10:26am
4
In the current macro I have:
bRebuild = swModel.ForceRebuild3(False)
If you change your "false" to "true", it doesn't solve the problem?
1 Like
remrem
November 16, 2015, 10:33am
6
You need to make sure you rebuild the right setup. Here it's the "Flat Pattern" that interests you.
Either as in example two you create a list of all the configs and you rebuild them one by one.
Or you make sure to select the right configuration by this method: swModel.ShowConfiguration2 (sConfigName)
Then you rebuild the model.
2 Likes
remrem
November 16, 2015, 10:36am
7
2 Likes
On the other hand, I don't understand the problem when you say
"- When I launch the macro, it, by reading my part family, creates unfolded states (Flat pattern) for all my configurations. No big deal, but the problem is that it also exports these configs, so I end up with duplicate parts." ... isn't that what you're asking when you say "I just want Sw to unfold each of the configs in my part family when you launch the macro and export it to dxf with the name of the config"?
(I'm not saying you're wrong, I'm saying that I don't understand ;) )
Edit: Haaa ok Remrem. That's why it doesn't work the way I want both the trues and the falses. I thought you were turning a function on or off
1 Like
bart
November 16, 2015, 10:43am
9
Yes@remrem ,
Basically, I don't care about "folded" configurations.
What interests me is to export all the flat pattern configs, but without flat pattern appearing in the name.
In the attached example, I just created a single config to do a test.
The config is called "1625"
I get these files
resultat.png
bart
November 16, 2015, 10:47am
10
@Coincoin, if basically I only want a config on both
I only want the unfolded of the room. So yes only the "flat pattern" config but removing the flat pattern suffix
1 Like
remrem
November 16, 2015, 10:53am
11
Given the code of the macro it's normal:
Since:
You open the SW file. You list the configurations. For each configuration:You select the configuration You rebuild You export the unfold view with the name of the config dnas the name of the dxf file
Do you have a way to differentiate the configurations detected?
Are all the files unfolded?
Can you post your complete code in a txt??
2 Likes
bart
November 16, 2015, 10:54am
12
This is the part that I have a hard time grasping:
"Dim FilePath as String Dim PathSize As Long Dim PathNoExtension As String Dim NewFilePath As String
FilePath = swModel.GetPathName PathSize = Strings.Len(FilePath)PathNoExtension = Strings.Left(FilePath, PathSize - 6)
NewFilePath = PathNoExtension + sConfigName & ". DXF"
Export Flat Pattern bRet = swModel.ExportFlatPatternView(NewFilePath, 1)
Next i
End Sub"
What I deduce from this, Sw exports each config with the name of the part, the name of the config with .dxf
And then export all the "flat pattern" configs
That's right?
bart
November 16, 2015, 10:57am
13
@remrem
To recognize my different parts, there will be its name (Type 1) and its length config (e.g. 1625)
Or T1 1625.dxf, the best would be to have T1 LG 1625.dxf
I'm attaching the macro
There, I manage to get Part name "LG"config name.dxf
+ Part name "LG" "config name" flat pattern.dxf
macro_export_famille_de_piece_dxf.txt
No, it creates a new name, then exports the flatPattern by attaching the new one to it
1 Like
remrem
November 16, 2015, 12:03pm
15
1 Like
remrem
November 16, 2015, 12:05pm
16
Here is an image with colors for more understanding.
Made with Notepad++
[Edit: ]
For the "name" it is a property?
Is the length a property or just iclus in the config name?
Can you send me a standard part to do tests?
capture.png
2 Likes
To get around the problem, I would tell you to add the following line after "FilePath=swModel.GetPathName"
if String.Left(sConfigName, pathSize-15) = "SM-FLAT-PATTERN" then 'Check if the last 15 characters of the name match SM-FLAT-PATTERN
next i' if yes, next config
else
And to resume the normal course of the macro afterwards without forgetting the "end if" before "Next i"
1 Like
bart
November 16, 2015, 12:57pm
18
You're a @remrem boss, with that, I understand better how macro works. =)
The name is just the name of the part, later, I'll just take the name of the config
(The T1, T2, T3, etc.. will become configs and no longer parts)
The name of the config is not too important as long as I get the log of the part in the name of the Dxf.
I am attaching the document in question
corniere.zip
bart
November 16, 2015, 1:05pm
19
We are approaching perfection.
To get around the flat pattern problem, I created derived configurations instead of the classic cofigurations.
So I end up with just my unfolded with the right name associated with it.
Just @remrem if you can take a look at my room family, see if you would have done the same.
Thanks again! =)
resultat_2.png
1 Like
bart
November 16, 2015, 1:21pm
20
Small improvement:
To make everything flawless, I'd like to replace the om of the room (PatchNoExtension) with a personal property.
I have added in my family of rooms and in my properties a "type" line
I would like it to appear in the name of the dxf.
Example: T1(type) LG 16455(config name).dxf