How to detect if note/block is future version?

I'm adding blocks and notes automatically with my add-in, both directly and with drag and drop. Both of these methods fail when the block or note is saved in a future version.

Is there a way to detect the version for these kinds of files with the API? I know how to do it for models, but those methods fail for annotations.

SolidworksApi/macros
Answers 2
JN
JN 2021-04-08 Best Answer

Witch language are you using ? I don't think you can get the version of a block file, but you can manage exception.

Setup a try catch (here an exemple in vb.net):

Try<br><br><span class="string token">'Your code to insert block'</span><br><br>Catch ex As Exception<br><br><span class="token function">MsgBox</span><span class="punctuation token">(</span>ex<span class="punctuation token">.</span>Message<span class="punctuation token">)</span> <span class="string token">'Exception message maybe something like "future version blablabla"'</span><br>    Exit sub<br><br>End Try‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍<span class="line-numbers-rows"><span>‍</span><span>‍</span><span>‍</span><span>‍</span><span>‍</span><span>‍</span><span>‍</span><span>‍</span><span>‍</span><span>‍</span></span>

PB
PB 2021-04-08

My products are all in C#. Your solution is exactly what I currently do. The Add method returns null when adding the note or block fails, so I check for that. But a future version file is not the only reason it might fail, so I was hoping I could check the version directly like I do with models.

SolidWorks sends you three messages when you add a block manually and it fails, one of them is a future version warning. So it can be done, probably just with the API.