How to activate viewports in mechanical using script?

prakasjp
prakasjp Member Posts: 2
First Comment
**

Dear Team,

I am using four viewports in mechanical. As i need to save the image in each view port. I am looking for the the API to activate the viewport before saving the image via script.

Thanks in Advance

Tagged:

Answers

  • Chris Harrold
    Chris Harrold Member, Administrator, Employee Posts: 183
    100 Comments 5 Answers First Anniversary Ansys Employee
    admin

    @AKD-Scripting-Team - someone from the AKD team should have some ideas for you.

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    Hi @prakasjp . Activating the four viewports option can be done through scripting, but with unsupported commands. By unsupported, we mean that they are not documented, might change in between versions, and we do not guarantee that it'll work.

    Here are the commands:

    import toolbar
    toolbar.DoGraphicsFourViewports(ExtAPI)
    

    By the way, when trying to find commands in Mechanical, you can try to use the recording. There's an option to also record unsupported commands:

    To activate this option, from the WB project schematic, go to Tools / Options / Mechanical and select this:

  • prakasjp
    prakasjp Member Posts: 2
    First Comment
    **

    Hello Pernelle,

         Thanks for your reply.  However, I am not looking for the API not to activate four viewports. I am looking for the API to activate one of viewport out of the four viewports to save the image in that view port. For example, after activating four viewports, i need to click on top of one of the view port (out of 4) inorder to save the image that i need. I need API for that. Please refer to the image attached with this.![](https://us.v-cdn.net/6037473/uploads/editor/gb/qs3nmgslmlr6.png "")
    
  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 871
    100 Answers 500 Comments 250 Likes First Anniversary
    ✭✭✭✭

    Hello @prakasjp , sorry for the misunderstanding. There was some formatting issue in your previous message and the image did not got through. I hope I now understand what you'd like to do, but as far as I'm aware it's not possible to activate the image of one viewport before exporting it. I would recommend using one viewport only and activate the object you'd like to export a picture of from the tree. There's also some view options that you can use to orient the model as you'd like it to be: https://discuss.ansys.com/discussion/1285/how-to-get-the-script-behind-graphic-camera-by-record-function-in-mechanical