Re: Obtaining Anno Scale of a saved view
Quote:
Originally Posted by
newfoundfreedom
I dont even really know where to start....
Not sure how familiar you are with loading .NET Assemblies, so I thought I'd share some info to help along the way....
First, download the .ZIP file from my previous post, or click here (to download by direct link).
Next, you will want to Right Click the .ZIP you just downloaded, and select Properties. Hit the "Unblock" button (Windows 7), and then hit Ok.
Extract the .ZIP file, and move or copy the resultant .DLL to a directory on your PC that resides within your Support File Search Paths (SFSP).
... There are many ways to do this next part, so feel free to deviate as you see fit. It is important to note that .NET assemblies can only be loaded once per session; subsequent NETLOADs have no affect. It doesn't hurt anything (AFAIK), but it is not of any value.
To simply test the .DLL you've just placed within SFSP, start a new session of AutoCAD, and use the NETLOAD command to load the .NET assembly, and test the newly added vla-Get-ViewAnnoScale LispFunction Method.
If you choose to incorporate this .NET assembly into your deployment, and would like it to be loaded each time you open AutoCAD, simply add this to your Acad.lsp file (presuming that you have write-access to this file):
Code:
(foreach dll '("vla-Get-ViewAnnoScale.dll"
;; <- other net assemblies here
)
(if (findfile dll)
(progn
(terpri)
(command "netload" dll))))
... So long as the .DLL file resides within SFSP, it will be loaded each time AutoCAD starts. There are other ways of accomplishing this, via the Registry, or via my Netload LispFunction Method for example, but that is not always necessary.
** Edit - You can load .NET assemblies that are stored on a network location, but that is not always recommended, and requires some modification to acad.exe.Config, and .NET 4.0 framework AFAIK.
HTH
Re: Obtaining Anno Scale of a saved view
Not entirely necessary to use .Net for this. The AnnoScale is saved as an extension dictionary to the view object. The VL stuff only gets you so far (Adesk "decided" to stop updating the ActiveX library some time back). For the rest you need to look into the raw DXF data. E.g. this would extract the anno scale's name from the view name:
Code:
(vl-load-com)
(defun GetViewAnnoScale (ViewName / view xDict annoScale)
(if (not (vl-catch-all-error-p
(setq view (vl-catch-all-apply
'vla-Item
(list (vla-get-Views (vla-get-ActiveDocument (vlax-get-acad-object))) ViewName)))))
(if (and (eq (vla-get-HasExtensionDictionary view) :vlax-true)
(setq xDict (vla-GetExtensionDictionary view))
(not (vl-catch-all-error-p (setq annoScale (vl-catch-all-apply 'vla-Item (list xDict "ADSK_XREC_VTR_ANNOSCALE_DATA"))))))
(cdr (assoc 300 (entget (cdr (assoc 340 (entget (vlax-vla-object->ename annoScale))))))))))
Re: Obtaining Anno Scale of a saved view
Or if you prefer the fully AutoLisp (no vl-stuff involved at all):
Code:
(defun GetViewAnnoScale2 (ViewName / view xDict annoScale)
(if (and (setq view (tblobjname "VIEW" ViewName))
(setq xDict (cdr (assoc 360 (entget view))))
(setq annoScale (dictsearch xDict "ADSK_XREC_VTR_ANNOSCALE_DATA")))
(cdr (assoc 300 (entget (cdr (assoc 340 annoScale)))))))
:lol:
Re: Obtaining Anno Scale of a saved view
Irneb, my bru - You always come through!
Thanks for clarifying the issue of where that data is stored (in DXF - I thought that's where it would be!), but I enjoyed doing the little .NET ditty, as I've really been trying to self-teach, so opportunities like this just help me learn, as well as help others.
One of these days, I'll cross the pond and we'll dop a few, for now... Cheers! :beer:
Re: Obtaining Anno Scale of a saved view
Wow - okay so there was a way to extract this through just LISP. Thanks for the tip. I am completely unfamiliar with the dictsearch function. I was just looking at the output of a (tblnext "view" viewname) and had not seen the DXF 360 group code listed. I will do some further research now that I see your code, but how did you know about the 360 group code?
By the way RenderMan - I never got back to you as I got totally caught up a few days ago. But your .NET function has worked beautifully - and I currently have my routine loading and calling it. Thank you for both writing it and the added support in all the help info you put in this post.
Re: Obtaining Anno Scale of a saved view
Quote:
Originally Posted by
newfoundfreedom
Wow - okay so there was a way to extract this through just LISP. Thanks for the tip. I am completely unfamiliar with the dictsearch function. I was just looking at the output of a (tblnext "view" viewname) and had not seen the DXF 360 group code listed. I will do some further research now that I see your code, but how did you know about the 360 group code?
Here's a starting point, the View Table, under DXF Reference... While this specific 'chapter' of the Developer Documentation does NOT show DXF 360 code for Views, I'm sure you can find it in proximity. I just didn't look hard enough, before hopping into .NET. :wink:
http://exchange.autodesk.com/autocad...2e719-7a49.htm
Quote:
Originally Posted by
newfoundfreedom
By the way RenderMan - I never got back to you as I got totally caught up a few days ago. But your .NET function has worked beautifully - and I currently have my routine loading and calling it. Thank you for both writing it and the added support in all the help info you put in this post.
You're welcome; I'm really glad you are finding it (the LispFunction Method) to be of use. Hopefully others will benefit as well.
Cheers! :beer:
Re: Obtaining Anno Scale of a saved view
Quote:
Originally Posted by
RenderMan
Irneb, my bru - You always come through!
Thanks for clarifying the issue of where that data is stored (in DXF - I thought that's where it would be!), but I enjoyed doing the little .NET ditty, as I've really been trying to self-teach, so opportunities like this just help me learn, as well as help others.
One of these days, I'll cross the pond and we'll dop a few, for now... Cheers! :beer:
Yep, it's always good to try different approaches. And as we've seen many a time - .Net does have its uses. Your code is quite nice BTW, quite comprehensively written. It does show up (however) just how much more a programmer needs to do in VB.Net/C# as compared to ALisp/VLisp. I mean, purely from a line count it's a whole lot more typing isn't it? And another thing I've been trying: how to actually pass an error code back to lisp - you know so it either starts the *error* function or gets caught in the vl-catch-all-apply.
Anyhow, I'm looking forward to meeting you one day. Who knows, perhaps I could even get sent over to the states on a project. We've been working on something in Cuba (and previously in Chile), so perhaps it would not be too out of this world for such to happen. Though at present I'm on a project next to the Caspian Sea, so it might be a while :roll:
Quote:
Originally Posted by
newfoundfreedom
Wow - okay so there was a way to extract this through just LISP. Thanks for the tip. I am completely unfamiliar with the dictsearch function. I was just looking at the output of a (tblnext "view" viewname) and had not seen the DXF 360 group code listed. I will do some further research now that I see your code, but how did you know about the 360 group code?
Yep, the tblnext/tblsearch gives you only a cut down version of the dxf codes. Notice I've used the tblobjname in my second post. That gives you a normal ename which can be passed to entget - giving you the entire dxf list (including xdata if you specify something in the appname argument for entget.
RM is correct that the extension dictionary stuff is less than perfectly documented in help. The 360 code is a common code - thus not documented under the VIEW table. You can find it here: http://exchange.autodesk.com/autocad...2e719-7a5b.htm
And even then the portion:
Quote:
This group exists only if persistent reactors have been attached to this object
Is a blatant LIE! Reactors are stored there (certainly), but they're one of a huge list of object links possible under the XDictionaries.
Re: Obtaining Anno Scale of a saved view
Quote:
Originally Posted by
irneb
Yep, it's always good to try different approaches. And as we've seen many a time - .Net does have its uses. Your code is quite nice BTW, quite comprehensively written. It does show up (however) just how much more a programmer needs to do in VB.Net/C# as compared to ALisp/VLisp. I mean, purely from a line count it's a whole lot more typing isn't it? And another thing I've been trying: how to actually pass an error code back to lisp - you know so it either starts the *error* function or gets caught in the vl-catch-all-apply.
Absolutely there's more code by comparison, and thanks for the compliment!
Somewhat laughably, that is why you'll see that most of my .NET offerings are LispFunction Methods, to pick up where we've left off. I'm not sure of the exact count, but between LispFunctions that I've completed (i.e., capslock, dll, getowner, netload, numlock, scrolllock, vla-get-viewannoscale, etc.), and those I am still developing (starting with the Lay* functions, similar to the commands already available just for practice iterating the collection objects using Transactions, and adding LayRec[oncile] functionality), I'm really trying to dig into .NET... Just started reading Andrew Troelsen's "Pro C# 2010 and the .NET 4 Platform"... +1700 pages of light reading! LoL
This is where I've been wanting to better understand Exception handling, and the ResultBuffer - Jeff, Dgors, Gile, and even Tony himself have been most helpful. I just need a better understanding of the fundamentals still... I still mistakenly call a Namespace a Class, etc. LoL
Quote:
Originally Posted by
irneb
Anyhow, I'm looking forward to meeting you one day. Who knows, perhaps I could even get sent over to the states on a project. We've been working on something in Cuba (and previously in Chile), so perhaps it would not be too out of this world for such to happen. Though at present I'm on a project next to the Caspian Sea, so it might be a while :roll:
... Well, if / when you're in the neighborhood, we'll have you over and we'll throw back several frosty brews, and I'll grill us up something that had parents. :beer: