Lee Roy Posted July 9, 2012 Posted July 9, 2012 I'm looking to do an If/Then for a list of AEC Project Numbers. However, I can't find the AEC Project Number field to create the list. I'm stuck before I start. Help? Thank you. Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 Is this for Revit (which you list as using), or for an AutoCAD Vertical? AFAIK, Revit is relegated to .NET development, whereas AutoCAD products allow for LISP development; just not for all aspects of the Database. If the latter we should be able to help you out. Just post what version, and vertical you're using. Quote
Lee Roy Posted July 9, 2012 Author Posted July 9, 2012 Sorry, it's for AutoCAD MEP 2011/2012. We use all Revit's and ACAD's, I just prefer Revit. Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 No worries; just wanted to clarify... I have AMEP 2012 installed, I'll skim the Developer Documentation. Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 Give this a try: (vl-load-com) (defun c:ProjectHistory (/ key descendents) (setq key (strcat "HKEY_CURRENT_USER\\" (vlax-product-key) "\\Project History\\" ) ) (if (setq descendents (vl-registry-descendents key "")) (progn (terpri) (prompt "\n >> PROJECT HISTORY ") (terpri) (textpage) (foreach val descendents (prompt (vl-registry-read key val)) ) ) (prompt (strcat "\n** No projects found ** \n" key)) ) (princ) ) Quote
Lee Roy Posted July 9, 2012 Author Posted July 9, 2012 What should I be expecting as an output? I got a huge history of my project navigator. Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 What should I be expecting as an output? I got a huge history of my project navigator. You received exactly what the code was supposed to do... I needed to know if I am looking at the correct information, before I can push that info into any other format (i.e., the IF/COND statement in the OP). If this information is not correct, then I'm putting the cart before the horse, so-to-speak. ... Is this the information you want to compare against? Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 Oh... Each descendent for that registry key has a number; not sure if that is the project number, or if it is just an AMEP generated number? I don't really know enough about AMEP frankly. We're just testing it to see if it is a viable addition to our Civil 3D projects for buried pressure pipes. Any clarification would make my helping easier (if not possible! LoL). Quote
Lee Roy Posted July 9, 2012 Author Posted July 9, 2012 Kind of... Z:\Active Projects\\() \AutoCAD Project Navigator\\.apj Our file structure puts the project number in the directory path, so the text is there. Drawing on that would be difficult as the directory changes from one project to the next, so the length of the directory path would never be a constant. I was thinking that AutoCAD would also hold the Project Number in an AEC field. In Project Navigator, Project tab, the "Number" field. Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 I'm not worried about the file path being inconsistent, as I can simply parse the file path into a list of strings which represent the directories, as shown here. I still must be missing something, I just don't know what ??? Quote
Lee Roy Posted July 9, 2012 Author Posted July 9, 2012 When I insert the field into a document, the "Field expression" is %%. -EDIT- That's what I'm looking for. I don't know how to put that Field expression into a lisp. Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 (edited) When I insert the field into a document, the "Field expression" is %%. -EDIT- That's what I'm looking for. I don't know how to put that Field expression into a lisp. Why didn't you say so in the first place! (vl-load-com) (defun c:FOO (/ ss) (prompt "\nSelect text entity to replace \"TextString\" with AEC Project Number: ") (if (setq ss (ssget ":S:E:L" '((0 . "TEXT,MTEXT")))) (vla-put-textstring (vlax-ename->vla-object (ssname ss 0) ) "%<\AecPr \"ProjectNumber\">%" ) ) ) Edited July 9, 2012 by BlackBox Quote
Lee Roy Posted July 9, 2012 Author Posted July 9, 2012 LOL Yes, that's the data I want. Ok, so I want to do something similar to: (for now, later will be a list) (vl-load-com) (defun c:blah (/ projnum) (setq projnum .............) (if (= projnum "1000.00") (c:plotstyle1) (t (c:plotstyle2) ) ) ) c:plotstyle1 and c:plotstyle2 are defined elsewhere. How do I set %% to the "projnum" variable? Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 (edited) You can either pull from the eName's DXF 1, or the Vla-Object's TextString Property. I'd personally use the latter, as I would also be sure to incorporate a FieldCode validation first; example: (defun _GetTextStringIf (oText fieldCode) (if (= fieldCode (vla-fieldcode oText)) (vla-get-textstring oText) ) ) (defun c:FOO (/ ss v) (if (and (setq ss (ssget ":S:E:L" '((0 . "TEXT,MTEXT")))) (setq v (vlax-ename->vla-object (ssname ss 0))) ) (prompt (_GetTextStringIf v "%<[b][color=red]\[/color][/b]\AecPr \"ProjectNumber\">%")) ) (princ) ) Edited July 9, 2012 by BlackBox _GetTextStringIf simplified Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 I get "bad argument type: stringp nil" Sorry about that, I neglected the double-backslash required (i.e., "\\"), which represents the single-backslash "\" within the FieldCode String. See the revised code in my earlier post here. Quote
Lee Roy Posted July 9, 2012 Author Posted July 9, 2012 Cool, that's working. Now how do we get it to pull that value without clicking on a field? I've got millions of things running through mind, so i'm trying to explain this as best as I can... So that when you run the command, it automatically pulls the value from the activedocument. I want my function (think acaddoc) to assign "plotstyle1" by default except when the activedocument's ProjectNumber (%%) matches a specific value (ie "1000.00") in which case it assigns "plotstyle2". I don't want to have to click anything. I really appreciate your help! Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 Well, as we do not use AMEP for production, I do not have a document on which to test for myself... One that has a valid project, etc.. The best I can think of, is to start culling the Properties of various AMEP Objects, using vlax-dump-object... I am unsure of where the AMEP ActiveX Reference is, but I was able to piece this code together for dumping 2011 or 2012 AecX.AecBaseApplication's Interface Object, perhaps the 'project' Property you're after resides there (I am really not sure to be honest): ((lambda (key / aecx) (if (and (setq aecx (cond ((vl-string-search "R18.1" key) "6.5") ((vl-string-search "R18.2" key) "6.7") ) ) (setq aecx (strcat "AecX.AecBaseApplication." aecx)) ) (progn (vlax-dump-object (setq aecApp (vla-getinterfaceobject (vlax-get-acad-object) aecx) ) T ) (vlax-release-object aecApp) ) (prompt "\n** Only AutoCAD MEP 2011, 2012 supported ** ") ) ) (vlax-product-key) ) HTH Quote
BlackBox Posted July 9, 2012 Posted July 9, 2012 For the hell of it, what does this return: (getvar 'projectname) .... ??? Quote
Lee Roy Posted July 9, 2012 Author Posted July 9, 2012 For the hell of it, what does this return: (getvar 'projectname) .... ??? Thank for all your help. Even if you can't get it spot on, you're giving me plenty of info to run with. That returns "" Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.