Using the Apprentice Server to extract dxf files of sheet metal parts

Using the Apprentice Server to extract dxf files of sheet metal parts

ewcler
Enthusiast Enthusiast
731 Views
3 Replies
Message 1 of 4

Using the Apprentice Server to extract dxf files of sheet metal parts

ewcler
Enthusiast
Enthusiast

Could the FileSaveAs property of the ApprenticeServerComponent be used in some way to export a dxf of a flat pattern? If it could, then I could reduce the opportunity for errors due to old versions of files being cut by our laser operators.  Basically if someone forgets to export an update after an edit is made, then our laser operators could inadvertently cut an old version. But, if we could set it up so that they created the dxf file when they were ready to program the part, they would always have the latest version. It would be a deal breaker if we had to set up a full version of Inventor on their machines to do this.  

 

 

Thanks in advance!

Eddie Cler
Paul's Machine & Welding Corp.
Dell Precision T3600- Xeon E5-1620 @ 3.6 GHz 32GB Ram - Nvidia Quadro 4000 Windows 7
0 Likes
732 Views
3 Replies
Replies (3)
Message 2 of 4

Owner2229
Advisor
Advisor

Hi. Well, you can't use the FileSaveAs, but you can try this instead:

Note: It can't create the flat pattern (unfold the sheet metal).

 

Dim iApp As New ApprenticeServerComponent
Dim oDoc As ApprenticeServerDocument = iApp.Open("SourceFile")
If oDoc.DocumentSubType.DocumentSubTypeID = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Dim oCD As ComponentDefinition = oDoc.ComponentDefinition If oCD.HasFlatPattern Then Dim sFN As String = oDoc.FullFileName Dim LNP As Integer = InStrRev(sFN, ".", -1) sFN = Left(sFN, oLP) & "dxf" Dim sOut As String = "FLAT PATTERN DXF?AcadVersion=R12" Try oCD.DataIO.WriteDataToFile(sOut, sFN) Catch ex As Exception MsgBox(ex.Message) End Try End If End If oDoc.Close() iApp.Close()

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 4

ewcler
Enthusiast
Enthusiast

Mike, 

Sorry for the really late reply...

I tried this in Visual Studio and I included a COM reference to the Inventor library, but the code errors out on the iApp.open method. 

Any ideas on what I am missing? 

2017-11-15_11-27-14.jpg

 

Eddie Cler
Paul's Machine & Welding Corp.
Dell Precision T3600- Xeon E5-1620 @ 3.6 GHz 32GB Ram - Nvidia Quadro 4000 Windows 7
0 Likes
Message 4 of 4

Owner2229
Advisor
Advisor

Hey Eddie, the code should work as you have it (you've even corrected "oLP" to "LNP") in:

sFN = Left(sFN, LNP) & "dxf"

 

So, my guess would be it's either Visual Studio issue or the apprentice doesn't like that the file is in temp folder.

Try moving the file to e.g. your desktop.

You can also try running VS as admin.

You also can't run the code from another thread *.

You also can't run the code from a service *.

If everything fails you can try playing with your target CPU (Any 64-bit, Any 32-bit, etc.).

 

* You can but it requires some extra work.

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes