Capture Screenshot in HyperMesh

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A

Hello,

 

Complete newbie here.

 

I am trying to highlight a few elements and capture screenshot in HyperMesh.

This is the code I have put together by referring to command.cmf file:

 

*unmaskall()
*createmark(systems,1) 'all'
*maskentitymark(systems,1,0)
*createmark(elements,1) 101 102 103 104
*maskentitymark(elements,1,0)
*maskreverse(elements)
*createmark(elements,1) 101 102 103 104
*numbersmark(elements,1,1)
*window(0,0,0,0,0)
after 500
*jpegfilenamed 'Capture.jpg'

 

Everything works as expected except for the last command to save screenshot. Interestingly, if I give this last command separately in the command window, it works fine.

 

Any ideas?

 

Thanks,

Ayush

Answers

  • Pandurang
    Pandurang Altair Community Member
    edited August 2018

    try removing quotes around Capture.jpg

     

    try this:

     

    *jpegfilenamed Capture.jpg

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2018

    Still doesn't work.

     

    I tried hm_windowtofile as well. It has the same issue. Works from command window, but doesn't work as part of the script.

     

    I am using HM11, if that's relevant.

  • Pandurang
    Pandurang Altair Community Member
    edited August 2018

    What is error msg ?

  • vipin_22401
    vipin_22401 Altair Community Member
    edited August 2018

    Hello,

     

    Complete newbie here.

     

    I am trying to highlight a few elements and capture screenshot in HyperMesh.

    This is the code I have put together by referring to command.cmf file:

     

    *unmaskall()
    *createmark(systems,1) 'all'
    *maskentitymark(systems,1,0)
    *createmark(elements,1) 101 102 103 104
    *maskentitymark(elements,1,0)
    *maskreverse(elements)
    *createmark(elements,1) 101 102 103 104
    *numbersmark(elements,1,1)
    *window(0,0,0,0,0)
    after 500
    *jpegfilenamed 'Capture.jpg'

     

    Everything works as expected except for the last command to save screenshot. Interestingly, if I give this last command separately in the command window, it works fine.

     

    Any ideas?

     

    Thanks,

    Ayush

     

    Hi @Ayush01 

    are you directly writing this code inside userpage file?

    if so change the line to

    *jpegfilenamed(Capture.jpg)

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited August 2018

     

    Hi @Ayush01 

    are you directly writing this code inside userpage file?

    if so change the line to

    *jpegfilenamed(Capture.jpg)

     

    @vipin: Noooooooooo, it's WRONG!

     

    @Ayush01: Try fullpath for JPG file, something like 'C:/Temp/capture.jpg' instead of 'capture.jpg'. It works for my script.

  • vipin_22401
    vipin_22401 Altair Community Member
    edited August 2018

    @Q.Nguyen-Dai yes it works for .tcl file, but i am not sure in what format he has written.

    if it is .mac file we have to write it inside brackets ().

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited August 2018

    I was saving it in a .cmf file.

     

    I got it working now with the following code, and tcl format:

     

    *unmaskall
    *createmark systems 1 'all'
    *maskentitymark systems 1 0
    *createmark elements 1 101 102 103 104
    *maskentitymark elements 1 0
    *maskreverse elements
    *createmark elements 1 101 102 103 104
    *numbersmark elements 1 1
    *window 0 0 0 0 0
    *jpegfilenamed D:/Capture.jpg

     

    Thank you for suggestions.

  • Q.Nguyen-Dai
    Q.Nguyen-Dai Altair Community Member
    edited August 2018

    In your script, you could :

    • Detect the current folder where's found your HM model and save your picture into this folder.
    • Make automatical increment number into picture file name, so you have 'Capture_001.jpg', 'Capture_002.jpg', 'Capture_003.jpg',....etc