I see a lot of threads about getting flat pattern DXF files for CNC use, I also see some about Virtual Components. I haven't seen any about getting Flat-Pattern DXF from Virtual Components. I've read up and practiced getting DXF for configurations in a .sldprt, but I kinda need to be able to get the flat pattern from a Virtual Component.
What I think I know about Virtual Components:
- they are a part or assembly file that is on local disk in some user/temp directory while the non-virtual parent is open.
- that local file is temporary and is removed when the containing assembly is closed. (like gone, bye, no-more)
- the file is saved (embedded) in the parent sldasm file then "extracted" back to the local temp dir when the assembly is opened again.
- they show up in PDM Contains tab of the real part
- have less than ideal default names
- if SW crashes and you haven't saved the non-virtual assembly, your changes to the VCs are gone
- be careful about renaming, some talk here about renaming the assembly or VCs can cause problems.
What I think I know about saving dxf from flat pattern in sldprt file:
- use ExportToDWG2()
- use dataAlignments [0.....0]
- it will use the Flat-Pattern Feature of the active configuration; ShowConfiguration2(myConfig)
- use SetUserPreference*Value() calls to use mapping file or other system settings that show up in Export -> DXF/DWG settings page.
- it sounds like the ExportToDWG2() uses a temporary slddrw to get a flat of the flat-pattern Feature then saves that as DXF?
What I've tried so far:
- successfully saving dxf from sldprt files where the selected configuration has a feature of type FlatPattern, running as a PDM file transition action task for several months.
- choose config based on "DXF" in config name else use Default, the other option is for complex parts that we couldn't get flats for without manual edits under the Flat-Pattern feature.
- I go through the sub features of FlatPattern feature and unsupress all UiBend features, for some reason people occasionally leave unbend feature(s) suppressed in the Flat-Pattern.
- I've added code:
- when file is .sldasm to get a list of virtual components using most the code from: 2019 SOLIDWORKS API Help - Get Paths and Titles of Parents of Virtual Component (C#) if ( ! comp.IsVirtual) then add it to a List
- next loop through that list running my existing code on each ModelDoc2 object.
- The ExportToDWG2 is called from a PartDoc that is cast from the ModelDoc2.
- to ExportToDWG2 parameter "Model Name" I pass my ModelDoc2.GetPathName().
- I'm concerned this may be an issue because the help page: 2019 SOLIDWORKS API Help - ExportToDWG2 Method (IPartDoc) says this is the path for the active document. But it looks like the sldasm is the active document at the moment.
- when file is .sldasm to get a list of virtual components using most the code from: 2019 SOLIDWORKS API Help - Get Paths and Titles of Parents of Virtual Component (C#) if ( ! comp.IsVirtual) then add it to a List
Needless to say the ExportToDWG2() is returning false right now and it seems there are a LOT of things that can cause that.
What's next:
- I'm going to first try to activate the virtual component
- If that doesn't work my next try will be to just take that path of the VC ["C:\\\\Users\\\\[user]\\\\AppData\\\\Local\\\\Temp\\\\swx1688\\\\VC~~\\\\1025826\\\\1025826^1025826.sldprt"] and open it with OpenDoc6() then save dxf from there which I have done manually.
Couple reasons for the post:
- If anyone has experience exporting Flat Pattern DXFs from Virtual Components I'd be grateful for any pointers. I'm sort of fellwalking here and I don't know if the solution is just over the next knoll or if it's still a thousand miles away.
- I couldn't find any other threads about this, so I'll start one and update it as I move along.
