Community
HSM Post Processor Forum
cancel
Showing results forย 
Showย ย onlyย  | Search instead forย 
Did you mean:ย 

Change image on Inventor Setup Sheet

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
robert.hempelFQCMR
592 Views, 12 Replies

Change image on Inventor Setup Sheet

Hello ๐Ÿ™‚

 

I was wondering if there is a way to change the image displayed on the setup sheet.

By default the current view of the model will be displayed. Ideally I would like to

display an idw page. Alternatively I would like to change the path to a screenshot of an idw.

Is this possible by editing something in this code snippet of the .cps file?

 

 

  if (getProperty("showPreviewImage")) {
    var patternId = currentSection.getPatternId();
    var show = false;
    if (getProperty("forcePreview") || !seenPatternIds[patternId]) {
      show = true;
      seenPatternIds[patternId] = true;
    }
    if (show && currentSection.hasParameter("autodeskcam:preview-name")) {
      var path = currentSection.getParameter("autodeskcam:preview-name");
      var absPath = FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), path);
      if (FileSystem.isFile(absPath)) {

        if (getProperty("embedImages") && (revision >= 41366)) {
          src=getImageAsImgSrc(absPath);
          FileSystem.remove(absPath);
        } else {
          src=encodeURIComponent(path);
        }

        var r2 = "<table class=\"info\" cellspacing=\"0\">" +
          makeRow("<td class=\"preview\"><img src=\"" + src + "\"/></td>") +
          "</table>";
        write(
          "<tr class=\"info\">" +
          "<td colspan=\"4\" valign=\"top\" align=\"center\">" + r2 + "</td>" +
          "</tr>"
        );
      }
    }
  }

 

Labels (1)
12 REPLIES 12
Message 2 of 13

Hi @robert.hempelFQCMR 

 

when you are "posting" the setup sheet, the system is using this keyword from the top of the post,  to grab the picture:

keywords = "MODEL_IMAGE";

 

See the API help file for further reference:

https://cam.autodesk.com/posts/reference/keywords.html

 

But that means we can't select which picture will be generated.

If you want to use your own picture, you must find a way to create it before posting, the add a property to select your picture and use this one instead of the one generated automatically in the output folder.

 

Regards.


______________________________________________________________

If my post answers your question, please click the "Accept Solution" button. This helps everyone find answers more quickly!



Serge.Q
Technical Consultant
cam.autodesk.com
Message 3 of 13

Hi @serge.quiblier,

 

thanks for your answer. Unfortunately I don't quite understand what you mean by "using this keyword from the top of the post".

At what point do I use this keyword? Could you please give me an example?

 

Greetings!

Message 4 of 13

Hi @robert.hempelFQCMR 

 

You didn't really use it yourself, but the post you are using, is declaring this variable at the top of it's script.

Extracting the first lines of the setup sheet post processor we can see this :

/**
  Copyright (C) 2012-2021 by Autodesk, Inc.
  All rights reserved.

  Setup sheet configuration.

  $Revision$
  $Date$

  FORKID {BC98C807-412C-4ffc-BD2B-ABB3F0A59DB8}
*/

description = "Setup Sheet (HTML)";
vendor = "Autodesk";
vendorUrl = "http://www.autodesk.com";
legal = "Copyright (C) 2012-2021 by Autodesk, Inc.";
certificationLevel = 2;

longDescription = "Setup sheet for generating an HTML document with the relevant details for the setup, tools, and individual operations. You can print the document directly or alternatively convert it to a PDF file for later reference.";

capabilities = CAPABILITY_SETUP_SHEET;
extension = "html";
mimetype = "text/html";
keywords = "MODEL_IMAGE PREVIEW_IMAGE";
setCodePage("utf-8");
dependencies = "setup-sheet.css";

 

Please notice the line beginning by keywords, in the last extracted lines.

MODEL_IMAGE is telling Fusion that before posting the file, it need to create a picture representing the model and save it to the folder where the outputted will be generated. Then it add the name of this picture in the intermediate file providing the information to the post engine for the output generation (gcode, or setup sheet).

 

You don't have the choice of what will be generated. It's the model... and the model only.

When you add PREVIEW_IMAGE
The post configuration can use preview images for each operation.

PREVIEW_IMAGE_ALWAYS

The post configuration expects a preview image for every operation.

 

Regards.


______________________________________________________________

If my post answers your question, please click the "Accept Solution" button. This helps everyone find answers more quickly!



Serge.Q
Technical Consultant
cam.autodesk.com
Message 5 of 13
AchimN
in reply to: robert.hempelFQCMR

You can do the following to get a custom image into your setup sheet:

 

1. Add this property to the properties of your setup sheet post:

 

 

customImage: {
  title : "Custom image",
  description: "Select a custom image file to be displayed in the setup sheet",
  type : "file",
  value : "",
  scope : "post"
}

 

 

 

2. Search for this code in the setup sheet post:

 

 

        var path = FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), modelImagePath);
        var src="";
        if (!FileSystem.isFile(path)) {
          warning(subst(localize("Model image doesn't exist '%1'."), path));
        } else {
          if (getProperty("embedImages") && (revision >= 41366)) {
            // add support for image from database instead
            src=getImageAsImgSrc(path);
            FileSystem.remove(path);
          } else {
            src=encodeURIComponent(modelImagePath);
          }
        }

 

 

 and replace it with this:

 

 

        if (getProperty("customImage") == "") {
          var path = FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), modelImagePath);
        } else {
          var path = getProperty("customImage");
        }
        var src="";
        if (!FileSystem.isFile(path)) {
          warning(subst(localize("Model image doesn't exist '%1'."), path));
        } else {
          if (getProperty("embedImages") && (revision >= 41366)) {
            // add support for image from database instead
            src=getImageAsImgSrc(path);
            if (getProperty("customImage") == "") {
              FileSystem.remove(path);
            }
          } else {
            src=encodeURIComponent(modelImagePath);
          }
        }

 

 

 

When this is done, the following property will show up in your post process dialog and by right click you are able to select your desired image file:

AchimN_1-1669973147353.png


Result:

AchimN_2-1669973296922.png

 



Achim.N
Principal Technology Consultant
Message 6 of 13
robert.hempelFQCMR
in reply to: AchimN

Hi @AchimN ,

 

thanks for your answer, that's just the way we intented! Unfortunately the code doesn't work for me.

That's my properties:

properties = {
  embedStylesheet: {
    title      : "Embed stylesheet",
    description: "Embeds the stylesheet in the HTML code.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  useUnitSymbol: {
    title      : "Use unit symbol",
    description: "Specifies that symbols should be used for units (some printers may not support this).",
    type       : "boolean",
    value      : false,
    scope      : "post"
  },
  showDocumentPath: {
    title      : "Show document path",
    description: "Specifies that the document path should be output.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  showModelImage: {
    title      : "Show model image",
    description: "If enabled, a model image will be included in the setup sheet.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  showToolImage: {
    title      : "Show tool images",
    description: "If enabled, tool images will be included in the setup sheet.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  showPreviewImage: {
    title      : "Show preview image",
    description: "If enabled, a preview image will be included in the setup sheet.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  previewWidth: {
    title      : "Preview width",
    description: "Specifies the width of the preview image.",
    type       : "string",
    value      : "8cm",
    scope      : "post"
  },
  showPercentages: {
    title      : "Show percentages",
    description: "Specifies that the percentage of the total cycle time should be shown for each operation cycle time.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  showFooter: {
    title      : "Show footer",
    description: "Specifies whether a footer should be included in the HTML setup sheet.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  showRapidDistance: {
    title      : "Show rapid distance",
    description: "Specifies whether the rapid distance should be output.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  rapidFeed: {
    title      : "Rapid feed",
    description: "Sets the rapid traversal feedrate. Set this to get more accurate cycle times.",
    type       : "number",
    value      : 5000,
    scope      : "post"
  },
  toolChangeTime: {
    title      : "Tool change time",
    description: "Sets the tool change time in seconds. Set this to get more accurate cycle times.",
    type       : "number",
    value      : 15,
    scope      : "post"
  },
  showNotes: {
    title      : "Show notes",
    description: "Writes operation notes as comments in the outputted code.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  forcePreview: {
    title      : "Force preview",
    description: "Enable to force a preview picture for all instances of a pattern.",
    type       : "boolean",
    value      : false,
    scope      : "post"
  },
  showOperations: {
    title      : "Show operations",
    description: "Enable to output information for each operation.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  showTools: {
    title      : "Show tools",
    description: "Enable to see information for each tool.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  showTotals: {
    title      : "Show totals",
    description: "Enable to see total information.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  embedImages: {
    title      : "Embed images",
    description: "If enabled, images are embedded into the HTML file.",
    type       : "boolean",
    value      : true,
    scope      : "post"
  },
  customImage: {
    title : "Custom image",
    description: "Select a custom image file to be displayed in the setup sheet",
    type : "file",
    value : "",
    scope : "post"
  }โ€‹
};

 

That's the other part of the code:

 if (modelImagePath && getProperty("showModelImage")) {
        if (getProperty("customImage") == "") {
          var path = FileSystem.getCombinedPath(FileSystem.getFolderPath(getOutputPath()), modelImagePath);
        } else {
          var path = getProperty("customImage");
        }
        var src="";
        if (!FileSystem.isFile(path)) {
          warning(subst(localize("Model image doesn't exist '%1'."), path));
        } else {
          if (getProperty("embedImages") && (revision >= 41366)) {
            // add support for image from database instead
            src=getImageAsImgSrc(path);
            if (getProperty("customImage") == "") {
              FileSystem.remove(path);
            }
          } else {
            src=encodeURIComponent(modelImagePath);
          }
        }

        ++numberOfColumns;
        var alignment = (numberOfColumns <= 1) ? "center" : "right";
        write("<td class=\"model\" align=\"" + alignment + "\"><img src=\"" + src + "\"/></td>");
      }

 

Have I done something wrong?

Message 7 of 13
AchimN
in reply to: robert.hempelFQCMR

Can you please share your setup sheet post? Iยดll have a look into it then.



Achim.N
Principal Technology Consultant
Message 8 of 13
robert.hempelFQCMR
in reply to: AchimN

Of course. Thank you!

Message 9 of 13
AchimN
in reply to: robert.hempelFQCMR

Seems that there is an illegal character at the end of your property:

AchimN_1-1673250010484.png



Achim.N
Principal Technology Consultant
Message 10 of 13
robert.hempelFQCMR
in reply to: AchimN

But the } needs to be there, doesn't it?

When I remove it still doesn't work.

What program are you using to view the file? I am using Notepad++, so I can't see any possible errors.

Message 11 of 13

Hello @robert.hempelFQCMR 

 

when using VSCode we have this warning message:

sergequiblier_0-1673254234643.png

 

Try to deleted the line 164 and 163, and the rewrite them in order to suppress this invisible character.

 

Regards.

 


______________________________________________________________

If my post answers your question, please click the "Accept Solution" button. This helps everyone find answers more quickly!



Serge.Q
Technical Consultant
cam.autodesk.com
Message 12 of 13
AchimN
in reply to: robert.hempelFQCMR

Yes it needs to be there, but the illegal character is after the ' } '.
Its probably the easiest when you delete that property from your post, copy my suggested code from this thread and paste that code again into your post. Works fine here.

I am using Visual Studio Code (for which we do have an addin which allows you to postprocess directly within VS Code during post editing)



Achim.N
Principal Technology Consultant
Message 13 of 13
robert.hempelFQCMR
in reply to: AchimN

Now it works! Thank you very much! ๐Ÿ™‚

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report