Export Flat Pattern to JPEG

Export Flat Pattern to JPEG

waynehelley
Collaborator Collaborator
509 Views
4 Replies
Message 1 of 5

Export Flat Pattern to JPEG

waynehelley
Collaborator
Collaborator

Hi all,

 

I have a .NET application where I'm exporting an image of a flat pattern view. Here is a snippet...

 

                SheetMetalComponentDefinition oSMCD = (SheetMetalComponentDefinition)oCD;
                if (oSMCD.HasFlatPattern)
                {
                    oSMCD.FlatPattern.Edit();
                }
                else
                {
                    oSMCD.Unfold();
                }
                string sOut = "FLAT PATTERN DXF?AcadVersion=R12" + //R12 is the only DXF format which FormFabs can open
                        "&OuterProfileLayer=CUT" +
                        "&InteriorProfilesLayer=CUT" +
                        "&MergeProfilesIntoPolyline=True" +
                        "&InvisibleLayers=IV_TANGENT;IV_ARC_CENTERS" +
                        ";IV_FEATURE_PROFILES_DOWN";  //this ensures etching doesn't accidentally end up reversed                     
                       
                if (noEtching)
                {
                    sOut = sOut + ";IV_BEND;IV_BEND_DOWN;IV_FEATURE_PROFILES"; //Additional invisible layers
                }
                else
                {
                    sOut = sOut +
                    "&UnconsumedSketchesLayer=ETCH" +
                    "&UnconsumedSketchesLayer Color=255;127;255" +
                    "&FeatureProfilesUpLayer=ETCH" +
                    "&FeatureProfilesUpLayerColor=255;127;255" +
                    "&BendLayer=ETCH" +
                    "&BendLayerColor=255;127;255" +
                    "&BendUpLayer=ETCH" +
                    "&BendUpLayerColor=255;127;255" +
                    "&BendDownLayer=ETCH" +
                    "&BendDownLayerColor=255;127;255";
                }
                //Job Specific DXF
                string jobSpecificFileNameWithPath = dxfFolder + "//" + oItem + ".dxf";
                oCD.DataIO.WriteDataToFile(sOut, jobSpecificFileNameWithPath);
                iDoc.SaveAs("C:" + "//" + "temp" + "//" + oItem + ".jpg", true);
 
The problem is that the JPEG exported is just a screenshot.  I Could really do with the image exporting as solid black lines on a black background.  I know its possible to set the 'Visual style' to 'Wireframe' through the API but the components end up barely visible because of the low line weight.
 
Cutting List.JPG
 
I've considered making it so that the script creates view in the Drawing environment but this seems a bit long winded.  I know I could probably look at opening each of the DXFs up in AutoCAD but I don't have any experience with the AutoCAD API.
 
Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes
510 Views
4 Replies
Replies (4)
Message 2 of 5

AlexFielder
Advisor
Advisor

Perhaps you could look at changing the background image to plain white (for the purposes of the export I mean)?

0 Likes
Message 3 of 5

waynehelley
Collaborator
Collaborator

Hi Alex,

 

Having the background set to white does help but here is where the issue of the lineweight being too thin becomes an issue.

 

Untitled.png

Wayne Helley
Inventor 2013 Certified Professional

Autodesk Inventor Professional 2023
Visual Studio 2022
Windows 10 Pro, 64-bit
0 Likes
Message 4 of 5

AlexFielder
Advisor
Advisor

That's an issue then. Perhaps you could create a drawing with a single view of the flat pattern and export that instead?

 

I haven't looked in ages,but I believe you can change the colours of the drawing sheet (away from the pale-vomit-colour default) - that should at least solve the lineweight issue.

Message 5 of 5

philip1009
Advisor
Advisor

As far as I know, you can't change the thickness of the edge lines when looking at the 3D model.  Making a temporary view in a drawing is likely your best route.  You can change the background of the drawing to be white instead of the pale yellow, that color is the default since it doesn't strain the eyes as much as white.  I don't know if it's possible or not to change that color through the API yet, it'd probably be easier to save the blank white drawing somewhere else:

background_edited.jpg

 

 

Then basically you'll have the code open the drawing, put in the flat view, save the jpeg, then close the drawing without saving it.

 

When you have the code figured out, here's some lines of code I recommend putting in:

SyntaxEditor Code Snippet

oApp = ThisApplication
oAddIns = oApp.ApplicationAddIns
oVault = oAddIns.ItemById("{48B682BC-42E6-4953-84C5-3D253B52E77B}")
oVault.Deactivate
oSilent = oApp.SilentOperation
oScreen = oApp.ScreenUpdating
oSilent = True
oScreen = False

The Application Silent Operation set to True will deactivate all regular Inventor pop-ups.  The Application Screen Updating set to False will stop rendering any new frames, this will speed up your code since Inventor won't waste resources updating the graphics on your screen.  If you have Autodesk Vault, deactivating the add-in will stop all Vault pop-ups from bothering you and pausing the code, otherwise remove that code if you don't have Vault otherwise Inventor will error.

 

Then after your code has finished creating the jpeg and closing the white drawing, run these lines of code to bring Inventor back to normal:

SyntaxEditor Code Snippet

oSilent = False
oScreen = True
oVault.Activate

 

Let us know if you have anymore questions.