mdbdesign Posted November 5, 2011 Share Posted November 5, 2011 Create lots of mline styles to draw piping for shop details. Now I am kind of lost which one is which one. I think field is my solution to label all pipes (mline style) used. Manually is OK but I need to speed-up process of marking. Because this is my first contact with field I am lost again. Field macro (?) is as below (from field dialog box): (%<\AcObjProp Object(%<\[color=red]_ObjId 2128066088[/color]>%).StyleName \f "%tc1">%) where red colored part is object ID. Try to script it but it stop on opening dialog box for field. field object select mline style uppercase Any idea to automatize labeling? Like: push button (command) select object pick insertion point ...and go to next. Thank you. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 5, 2011 Share Posted November 5, 2011 I don't believe there is a command-line version of the Field command, so you will need to create the field using ActiveX methods. Here is a quick example: (defun c:mlfield ( / dc en pt ) (while (progn (while (progn (setvar 'ERRNO 0) (setq en (car (entsel "\nSelect MLine: "))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, try again.")) ( (eq 'ENAME (type en)) (if (not (eq "MLINE" (cdr (assoc 0 (entget en))))) (princ "\nPlease Select an MLine.") ) ) ) ) ) (if (and en (setq pt (getpoint "\nSpecify Point for Field: "))) (vla-addtext ( (if (= 1 (getvar 'CVPORT)) vla-get-paperspace vla-get-modelspace) (setq dc (vla-get-activedocument (vlax-get-acad-object))) ) (strcat "%<\\AcObjProp Object(%<\\_ObjId " (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility dc) 'getobjectidstring) ) (vla-getobjectidstring (vla-get-utility dc) (vlax-ename->vla-object en) :vlax-false) (itoa (vla-get-objectid (vlax-ename->vla-object en))) ) ">%).StyleName \\f \"%tc1\">%" ) (vlax-3D-point (trans pt 1 0)) (getvar 'TEXTSIZE) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted November 5, 2011 Author Share Posted November 5, 2011 Wow, thank you, that was fast. How do I will know to use any: (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) OMG... Thank you again Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 5, 2011 Share Posted November 5, 2011 You're welcome How do I will know to use any: (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) OMG... Actually, that part is not necessary if you know for sure that the routine will only be used on either 64-bit or 32-bit (and not across both); since the methods for obtaining the ObjectID are necessarily different for 32-bit / 64-bit platforms. For a 32-bit platform, you would use: (itoa (vla-get-objectid <VLA-Object>)) However, this will not work in a 64-bit environment. Even using the alternative vla-get-objectid32 will not suffice since the conversion to a string will impose a 32-bit limit on the integer. So instead we use: (vla-getobjectidstring <Utility Object> <VLA-Object> <Hexadecimal?>) Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted November 5, 2011 Author Share Posted November 5, 2011 Most important: It is working. Thanks Lee for enlightening. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 6, 2011 Share Posted November 6, 2011 As an extension of the program I have posted in this thread, I have created a 'Quick Field' program. This program will allow you to very quickly create custom field commands for this kind of task. The program page on my site describes the program in a lot more detail - have a read and let me know if you have any problems using the program Lee Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted October 2, 2013 Author Share Posted October 2, 2013 Was trying to reuse this code to insert block name field into dwg screen Program asking to select block and again select block and nothing happen. What I did wrong? (defun c:blf ( / dc en pt ) (while (progn (while (progn (setvar 'ERRNO 0) (setq en (car (entsel "\nSelect block: "))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, try again.")) ( (eq 'ENAME (type en)) (if (not (eq "block" (cdr (assoc 0 (entget en))))) (princ "\nPlease Select an block.") ) ) ) ) ) (if (and en (setq pt (getpoint "\nSpecify Point for Field: "))) (vla-addtext ( (if (= 1 (getvar 'CVPORT)) vla-get-paperspace vla-get-modelspace) (setq dc (vla-get-activedocument (vlax-get-acad-object))) ) (strcat "%<\\AcObjProp Object(%<\\_ObjId " (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility dc) 'getobjectidstring) ) (vla-getobjectidstring (vla-get-utility dc) (vlax-ename->vla-object en) :vlax-false) (itoa (vla-get-objectid (vlax-ename->vla-object en))) ) ">%)._EffectiveName \\f \"%tc4" ) (vlax-3D-point (trans pt 1 0)) (getvar 'TEXTSIZE) ) ) ) ) (princ) ) (vl-load-com) (princ) Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted October 2, 2013 Author Share Posted October 2, 2013 Ok, resolved with "QuickField" but still would like to know, what is wrong with above codes (BLF) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 2, 2013 Share Posted October 2, 2013 Ok, resolved with "QuickField" but still would like to know, what is wrong with above codes (BLF) This: (not (eq "block" (cdr (assoc 0 (entget en))))) Should be: (not (eq "INSERT" (cdr (assoc 0 (entget en))))) And this: ">%)._EffectiveName \\f \"%tc4" Should be: ">%).EffectiveName \\f \"%tc4\">%" Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted October 2, 2013 Author Share Posted October 2, 2013 (edited) I changed as per instruction (I think so): (defun c:blf ( / dc en pt ) (while (progn (while (progn (setvar 'ERRNO 0) (setq en (car (entsel "\nSelect block: "))) (cond ( (= 7 (getvar 'ERRNO)) (princ "\nMissed, try again.")) ( (eq 'ENAME (type en)) (if (not (eq "INSERT" (cdr (assoc 0 (entget en))))) (princ "\nPlease Select an block.") ) ) ) ) ) (if (and en (setq pt (getpoint "\nSpecify Point for Field: "))) (vla-addtext ( (if (= 1 (getvar 'CVPORT)) vla-get-paperspace vla-get-modelspace) (setq dc (vla-get-activedocument (vlax-get-acad-object))) ) (strcat "%<\\AcObjProp Object(%<\\_ObjId " (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility dc) 'getobjectidstring) ) (vla-getobjectidstring (vla-get-utility dc) (vlax-ename->vla-object en) :vlax-false) (itoa (vla-get-objectid (vlax-ename->vla-object en))) ) ">%).EffectiveName \\f \"%tc4\">%" ) (vlax-3D-point (trans pt 1 0)) (getvar 'TEXTSIZE) ) ) ) ) (princ) ) (vl-load-com) (princ) and show me "too many arguments" error. What I screw up now? Edited October 3, 2013 by mdbdesign Code updated with "if", code updated again - WORKING Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 2, 2013 Share Posted October 2, 2013 I never said to remove the if : (not (eq "INSERT" (cdr (assoc 0 (entget en)))) (princ "\nPlease Select an block.") ) should be: (if (not (eq "INSERT" (cdr (assoc 0 (entget en))))) (princ "\nPlease Select an block.") ) Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted October 3, 2013 Author Share Posted October 3, 2013 I did find it on floor, must fall when copy and paste, saved before "if" disappear in vacuum. Sorry, I am late but my new living room set just arrived and got little fun (read: assembly) with it. Lee, I add "if" and got bushes (####) when insert text. Is it has anything to do with field formatting?!?!?! Sorry Lee, but this is my beginning with field:? Code in post #10 updated, line 9 (if (not (eq "INSERT" (cdr (assoc 0 (entget en))))) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 3, 2013 Share Posted October 3, 2013 I did find it on floor, must fall when copy and paste, saved before "if" disappear in vacuum. Lee, I add "if" and got bushes (####) when insert text. Is it has anything to do with field formatting?!?!?! I noticed another change that was not required.... "%<\\AcObjProp Object(%<\\effectiveName" should remain as: "%<\\AcObjProp Object(%<\\_ObjId " Quote Link to comment Share on other sites More sharing options...
mdbdesign Posted October 3, 2013 Author Share Posted October 3, 2013 Code in post #10 updated. Working now, Thank you Lee. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted October 3, 2013 Share Posted October 3, 2013 You're very welcome Marek Quote Link to comment Share on other sites More sharing options...
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.