Macro export unfolded dxf BIS

@Bart: For the next without for, it's because I had to reverse a line with the end if ... but I don't have anything to test the end of the program right now.

 

I'll try to see that tomorrow

 

@Damoon: So, do we get a little shot of cider with your brut de pomme?

1 Like

For drawing, it is used to be able to automatically insert properties for manufacturing...  

And it also removes the bending lines so that the DXF is directly "clean" for laser cutting.

That way I only have a drawing for the export with its own settings. 

@coin37coin for cider there is none in the Vendée here, it's the Trouspinette^^

1 Like

This is what I have.

 

What must I do? :p

 

Otherwise, with the other way, we're almost there! You just have to tell Sw to export only the flat patterns and to remove this famous flat pattern from the name.

 


sans_titre.png

You have to activate your references.  

To do this in you have to go to tool then reference and check the references as in the attached image


capture.png
1 Like

Well, don't make fun of you^^

 

Here's how my logic sees it.

I look forward to your comments:p


macro.txt
1 Like

I took up your way of doing things (the lines:

  NewFilePath = PathNoExtension + sConfigName & ". DXF"
 bRet = swModel.ExportFlatPatternView(NewFilePath, 1)     )

an option I didn't know^^

with my loops on the configs that "skips" the configs containing "SM-FLATPATTERN"

see attached file^^.


export-config.txt
2 Likes

I didn't know the code "is XXX like then goto".

Interesting way of proceeding and which lightens many lines. I will retain it

1 Like

@Bart, I looked at the macro you did.

 

Well obviously, my code of "If Strings.Left(sConfigName, PathSize - 15) <> "SM-FLAT-PATTERN" " doesn't work great (if at all).

 

On the other hand, for the record, be careful in your construction. The VBA has its own function to do and if you swap 2 lines it may or may not work;)

 

When you do

If Strings.Left(sConfigName, PathSize - 15) = "SM-FLAT-PATTERN" Then
PathNoExtension = Strings.Left(FilePath, PathSize - 6)
       bRet = swModel.ExportFlatPatternView(NewFilePath, 1)
       NewFilePath = PathNoExtension + sConfigName & ". DXF"

Basically, you're asking him to check that SM-FLAT-PATTERN is in the name

Remove 6 characters from the extension

Create the unfolded

You give the way to access.

 

But we should do it like that 

 

PathNoExtension = Strings.Left(FilePath, PathSize - 6)
If Strings.Left(sConfigName, PathSize - 15) <> "SM-FLAT-PATTERN" Then
       NewFilePath = PathNoExtension + sConfigName & ". DXF"
       bRet = swModel.ExportFlatPatternView(NewFilePath, 1)

Remove 6 characters from the name

If the config name is different (<>) from Flat Patterne

Give the path to the record

Create the unfolded

3 Likes

I went to bed at 1am.

 

I've been talking a lot, it's starting to come in... ^^

 

I made a medley of all your macros, I took what was interesting.

Everything works perfectly except for this flat pattern.

 

Actually, I don't need the name of the part, I just need to retrieve the name of the config to search in this name "SM-FLAT-PATTERN" and delete these characters.

 

With the formula "is XXX like then goto", Sw only exports the configs in Flat pattern, so exactly what I want. All that's left to do is clean up the file name.

1 Like

Hello

Post the latest version of your code in a TXT if you want help:)

 

1 Like

To get the right path you have to make a small modification...

see attached.

 


export-config.txt
2 Likes

50 answers! That's the question! =)

 

Here's where I am in the macro.

 

These are the lines I have to change:

PathNoExtension = Strings.Left(FilePath, PathSize - 6)
       NewFilePath = PathNoExtension & ". DXF"

File path is the name of the part, but I don't want it, I just want the name of the config (sConfigName) and remove "SM-FLAT-PATTERN"

I know, I'm rambling....^^

 

Thanks again in any case! Without you, I don't know how I would have done it!

On the other hand, to write down the best answer, it's going to be cotton....^^


macro.txt
2 Likes

Oh you only want the name of the config?

So replace the line 

NewFilePath = PathNoExtension & ". DXF"

by

NewFilePath = Left(FilePath, InStrRev(FilePath, "\")) & sConfigName & ". DXF"

 

Edit: with the macro cleaned up in PJ


macro-dxf-bart.txt
3 Likes

If I put sCofigName + dxf it will give me the name of the config (1548SM-FLAT-PATTERN) + dxf

 

I tried but it doesn't work, why can't we put

PathNoExtension = (sConfigName) , Pathsize -15 ? or something like that

2 Likes

Yes sorry, here is the corrected macro!

The syntax:

        NewFilePath = Left(FilePath, InStrRev(FilePath, "\")) & left(sConfigName, len(sConfigName)- 15) & ". DXF"
 

 


macro-dxf-bart.txt
2 Likes

Thank you Lucas! =) Nickel like that!

Finally, thank you all!!

 

Well, you're going to tell me I'm boring, but I'd like to add one last step................ :s

 

Just in front of the name of the config, I would like to add the type of the part (Type 1, Type 2 etc...)

This type, is a personal property that is visible in the part family.

So I modified the macro code to add this step, but inevitably, it freezes! ^^

 

After promising, I'll close the question! :D


macro_final.png
1 Like

Are you launching this from a map or from 3D?

Edit, try this (add the first two lines and modify the 3rd from the existing one): 

Dim TYPE as string

 

TYPE = SWmoddoc.GetCustomInfoValue("", "type")

NewFilePath = Left(FilePath, InStrRev(FilePath, "\")) & TYPE & left(sConfigName, len(sConfigName)- 15) & ". DXF"

2 Likes

From 3D

 

When I put Dim TYPE it tells me "Expected ocmpilation error: Identifier)

Same for the second line :/

1 Like

Oh yes, sorry "type" is reserved in VBA! Put TYP instead:

Dim TYP as string

TYP = SWmoddoc.GetCustomInfoValue("", "type")

NewFilePath = Left(FilePath, InStrRev(FilePath, "\")) & TYP & left(sConfigName, len(sConfigName)-15) & ". DXF"

 

Edit: by the way, the exact name of your property is "typical"?

3 Likes

The exact name of the property is TYPE

 

it returns values like 1 or 2 or 3 etc...

To get in the end: T1 Lg 1250.dxf

 

Compilation error: The swmoddoc variable is not set

What do I wear?

Dim Swmoddoc As ...........