If you are an avid keyboard user like me, then you probably share my contempt for the developers choice of mandating a dialog prompt for text entry on Plant 3D IsoMessages. I know it was a constant irritation of mine years ago when I was first using P3D. Especially since there were so many logical applications for standardized notes that could be made if they would just let me. Maybe I’m a pessimist for having so little faith in people (and myself) to be consistent, but I do think my personal experiences easily justify my dismal expectations of typical users.
Anyway, I recently had the misfortune of being subjected to that same anguish, but these days I am a much craftier automater. So, things have generally been going my way this time around and I will be talking about one of those many victories in this post.
During the course of this current project I’ve unfortunately had to dive VERY deep into the Plant SDK. Which is an absolute labyrinth and thankfully I am finally “caching on” to their philosophy. I still don’t like something this soupy and seemingly incoherent, but I will admit the crazy fast query of LineGroup data for the ENTIRE project is a pretty impressive byproduct of the choices they’ve made. Once I figured it out, it was a very small amount of code to export all the line group data to a csv, edit it in excel and put it back into the project database. I’ve done very similar tricks with CADmep, but it is a lot more messy and overhead intensive.
Having failed miserably with lisp years ago, one of my top agenda items this time around was automating the creation of standardize Iso Messages using the .Net API. I found almost no documentation in the SDK download and the only help the internet had to offer was some object Arx pseudo code that ultimately fell short of making a fully functional Iso Message Sphere. After a ton of ineffective web browsing and some deciphering of related code, I did gain fundamental insights on how these existed and related to other Plant objects. However, it was very disappointing to have my .Net attempt fail miserably like my lisp attempt did years before. I actually considered accomplishing my goal purely from post processing the PCF’s, but then I eventually picked up on the fact that numerous Iso Spheres derived from the same base class and set upon convincing a pig to act like a bull; which paid off!
The Iso Message, Floor Symbol, Insulation Symbol and Location Point all derived from the same .Net namespace of:
I also discovered that IsoSphere’s were essentially being claimed by a LineGroup and other than that they literally weren’t associated to anything. So, after some prodding I found that they had an AutoCAD extension dictionary, that contained an X-Record, that contained data, that Plant 3D makes some pretty wild behavioral changes based upon. I am still not sure if the first SafeArray list in my code has rigid values, but I’ve had zero issues with the static values I extracted from an existing Iso Message; the documentation says these are declarations of dxf data types and you can see that if you entget the xRecord. However, the important thing is that the X-Record name determined the actual Sphere type and that the 2nd SafeArray (Data argument) did allow me to set the Message value, the Box type and whether it was dimensioned! What does this all mean? Well, with some some old school command lisp puppeteering of the PLANTISOADDINFO command we can build our IsoMessages from any of the other derived Sphere types that do not involve dialogs. Once it exists, then we just have to superimpose the desired data we want onto it.
Note: The PLANTISOADDINFO does not let you provide a point from code, I assume Plant 3D is using a specialized version of point selection user input due to its need of making a relationship between the sphere and a LineGroup. Based on what I know about the P3D’s API, you should want it doing this heavy lifting of object associations anyway. It is very fickle and these are truly paper thin relationships that are likely impossible to rebuild from lisp after the fact if it doesn’t make the proper decision upon creation. Please correct me if you find a way to associate a sphere after creation using lisp or Plant 3D commands. With this trick and my .Net background, I could pretty much fabricate these things from scratch using a block reference, but it’s quite ugly.
(defun HOB:CreateIsoMessage (msg box dimed / lent nsa nsd dic rec obj) (setq lent (entlast) msg (acet-str-replace " " "@" msg) msg (acet-str-replace "\n" "$" msg)) (command "PLANTISOADDINFO" "L" pause) (if (/= (vl-princ-to-string lent) (vl-princ-to-string (entlast))) (progn (setq ent (entlast) obj (vlax-ename->vla-object ent) dic (vla-GetExtensionDictionary obj) rec (vla-item dic 0) nsa (vlax-make-safearray vlax-vbInteger '(0 . 2)) nsd (vlax-make-safearray vlax-vbVariant '(0 . 2))) (if (null dimed) (setq dimed 0) (setq dimmed 1)) (if (or (null box) (/= (type box) 'INT)) (setq box 0)) (vlax-safearray-put-element nsa 0 1) (vlax-safearray-put-element nsa 1 90) (vlax-safearray-put-element nsa 2 90) (vlax-safearray-put-element nsd 0 (vlax-make-variant msg vlax-vbString)) (vlax-safearray-put-element nsd 1 (vlax-make-variant dimed vlax-vbLong)) (vlax-safearray-put-element nsd 2 (vlax-make-variant box vlax-vbLong)) (vla-SetXRecordData rec nsa nsd) (vla-put-name rec "PnP3dMsg") ) ) ) ;Example function call (HOB:CreateIsoMessage "Stuff and Things\nCan't forget THINGS!" 1 1)
Probably more verbose than needed, but there just isn’t much information out there about these and I thought my process background would be a fine example of how I consistently manage to solve my real world problems. In the world of code, there really is no spoon. Enjoy the new utility…