Visible bounds includes invisible art from clipping mask
I am writing a script that makes fiducials around my design and to save material etc, I am resizing the artboard to the artwork using:
doc.artboards[0].artboardRect = doc.visibleBounds;
It works wonders, except if I have a clipping mask in the document because the "clipped"/invisible art is included in the visibleBounds it seems. Any suggestions on how to fix this?
Before making the clipping mask
How it looks after the clipping mask is made and I run my script
I have the same issue when deselecting everything and using the Artboards -> Fit To Artwork Bounds. However if I select the art and use the exact same function (not Fit to Selected Art) it does it correctly. So it kinda seems like a bug

