How to Automate Viewport Using Named Views

Hello, I am completely new to LISP. I have been trying to cobble together an automation process using ChatGPT, but I have been failing miserably. I would truly appreciate any help I can get here. Thank you!

I have a template that has Named Views set up for over a 150 different views.
Right now, we have to manually navigate to the layout, manually activate the viewport, and then manually select the view from a very long list of named views.
There are several differnt viewports that we need to do this for.
Some layouts only have a single viewport, and some layouts have several.
The View that gets picked is dependent on a few variables, which get entered into DWGPROPS and an Attribute Block with prompting from a previous LISP I created with ChatGPT.


Here is how it needs to work:

VIEWPORT A needs to be set to the NAMED VIEW that matches the value of DWGPROP A/ATTRIBUTE A.

then

VIEWPORT B needs to be set to the NAMED VIEW that matches the value of DWGPROP A/ATTRIBUTE B.

then it needs to do that for all the other viewports we have, regardless of how many there may be on a layout.

It feels like it should be rather easy since the variables are all determined before the LISP gets activated. I know at least part of it can be done since I was able to get it working if there was only one viewport on the layout. Multiple viewports on a layout seems to be the weak spot. It is failing to pick out the viewport with a unique identifier. I have tried using the Handle as well as setting them on layers unique to each viewport.

I anyone knows if this is possible, please let me know how it can be done. I will try to check back and answer any questions as time allows. Thank you!


-AJ








Comments

  • ALANH
    edited July 16

    Not sure why your using views, you can make a layout and set a viewport based on some sort of criteria using lisp, title block, scale, twist angle and so on. At moment I only do single viewports, and have different methods to make them, but the same methods could do multi viewports in one layout based on a pick point in model space and a scale, just repeat for each viewport.

    What are you drafting ?

  • ajax6677
    edited July 16

    Thank you for responding.

    Named Views was the only option I was aware of for saving specific views and being able to identify them.

    This is a development that has a few different models with several variations. Each variation has a dedicated space in model space, like Plan 1, Variation 1, Rotation 1 will always be located in the first position in model space.

    How would I set this up?

  • ALANH
    edited July 17

    If you look at this movie each rectang has a label. In this case a number, but the rectang can have xdata which is attached to the rectang. So you could select a name and that rectang will have that name. a corresponding layout is made that matches that rectang. I have multiple ways of doing the rectangs can be as simple as select a point in Model, a scale and Title block and the layout is made. In this image the viewport is rotated to suit. Have a look at the movie as well. In the case of the walk along pline option have made 44 layouts in one go. See image below.

  • After banging my head against a wall with ChatGPT for almost a month now, I have to admit defeat and get some help. I have learned a little more about this language, but it is woefully inadequate to solve this puzzle.

    Currently, the LISP works for 2 of the 3 viewports.
    It navigates to the right layout tab.
    Activates the correct viewport based on xdata.
    Locates the correct placeholder in model space by matching user input derived values to the placeholder xdata.
    Zooms to that placeholder to center it.
    Sets the scale correctly.
    Locks the viewport.
    Deactivates the viewport.

    Then it navigates to the other layout tab and repeats the process with two viewports on that page.

    Everything works great until it gets to the to the 3rd viewport. It will only set the scale. The view is not centered on anything.

    I have been through hundreds of iterations and trying different formulas and commands to get what I need, but I can't get any closer. I do not know enough about LISP, or BricsCAD specific commands to get myself any further.

    I will attach my dwg and the LISP. If anyone can get this last viewport to work, I would be so grateful.
    Thank you.

  • ALANH
    edited August 9

    I use rectangs to determine the required layout Mview not views, These rectangs are at scale and reflect the mview size for a title block. So you could do a rectang but as a block with a number eg "L2-1-1" when you make a 2 viewports it would do "L2-2-1" & "L2-2-2" a 3 viewports would give the rectang a "L3-3-1" "L3-3-2" "L3-3-3" so you can work out which layout each rectang is going into L1-1 = "Layout 1 with 1 mview. L3-2-2 is layout 2 second mview. Could also use the pline shape as a outline.

    I did not look too hard at code as I would use a different approach.

    The sample dwg is not really an indication of what is required, I understand copyright issues.

  • I am not using views anymore. Each of my rectangles has a unique identifier in xdata. I have the process completely laid out in the dwg to see the process I need. and the LISP has very detailed notes so it shouldn't be hard to follow, I hope.