mousho Posted September 10, 2020 Share Posted September 10, 2020 Hi everyone i need yours help again i'm trying copy field from one block to another block the problem is that in the end i cant see the resault and it show me #### only if i go inside the field and press ok it show me the resault any idea how to fix it MOLS.lsp Quote Link to comment Share on other sites More sharing options...
Tharwat Posted September 10, 2020 Share Posted September 10, 2020 Call the command REGEN after copying if your codes running correctly without any issue. Quote Link to comment Share on other sites More sharing options...
mousho Posted September 10, 2020 Author Share Posted September 10, 2020 1 hour ago, Tharwat said: Call the command REGEN after copying if your codes running correctly without any issue. i try it already its not refresh it maybe because its field inside field Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 10, 2020 Share Posted September 10, 2020 The main issue is that you are selecting the block reference with (car (entsel)). A block reference does not have a TextString property. (defun C:MOLS (/ att base blk doc obj sca space str) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq space (if (= 1 (getvar 'cvport)) (vla-get-paperspace doc) (vla-get-modelspace doc) ) ) (setq obj (car (nentsel "\nSelect an attribute: "))) (setq base (getpoint "\nSelect base point: ")) (setq str (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa(vla-get-ObjectID (vlax-ename->vla-object obj))) ">%).TextString \\f \"%tc1\">%")) (setq sca (getvar 'dimscale)) (setq blk (vla-insertblock space (vlax-3d-point base) "SH1" sca sca sca 0 ) ) (setq att (car (vlax-invoke blk 'getattributes))) (vla-put-textstring att str) (princ) ) Quote Link to comment Share on other sites More sharing options...
mousho Posted September 12, 2020 Author Share Posted September 12, 2020 ROY THX ITS WORK :) THE ISSUE IS THAT WORKING ONLY IF I DIRECTLY POINT ON THE ATTRIBUTE TEXT AND NOT THE BLOCK THERE IS ANYWAY TO CHANGE IT? OR ATLEAST IT WONT LET ME CHOOSE THE BLOCK Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 12, 2020 Share Posted September 12, 2020 (defun C:MOLS (/ attNew attSel base doc enmSel objNew objSel sca space str) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (and (setq enmSel (car (entsel))) (setq objSel (vlax-ename->vla-object enmSel)) (vlax-method-applicable-p objSel 'getattributes) (setq attSel (car (vlax-invoke objSel 'getattributes))) (setq base (getpoint "\nSelect Base Point: ")) ) (progn (setq space (if (= 1 (getvar 'cvport)) (vla-get-paperspace doc) (vla-get-modelspace doc) ) ) (setq str (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-objectid attSel)) ">%).TextString \\f \"%tc1\">%" ) ) (setq sca (getvar 'dimscale)) (setq objNew (vla-insertblock space (vlax-3d-point base) "SH1" sca sca sca 0 ) ) (setq attNew (car (vlax-invoke objNew 'getattributes))) (vla-put-textstring attNew str) ) ) (vla-endundomark doc) (princ) ) Quote Link to comment Share on other sites More sharing options...
mousho Posted September 13, 2020 Author Share Posted September 13, 2020 16 hours ago, Roy_043 said: (defun C:MOLS (/ attNew attSel base doc enmSel objNew objSel sca space str) (vl-load-com) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vla-endundomark doc) (vla-startundomark doc) (if (and (setq enmSel (car (entsel))) (setq objSel (vlax-ename->vla-object enmSel)) (vlax-method-applicable-p objSel 'getattributes) (setq attSel (car (vlax-invoke objSel 'getattributes))) (setq base (getpoint "\nSelect Base Point: ")) ) (progn (setq space (if (= 1 (getvar 'cvport)) (vla-get-paperspace doc) (vla-get-modelspace doc) ) ) (setq str (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-objectid attSel)) ">%).TextString \\f \"%tc1\">%" ) ) (setq sca (getvar 'dimscale)) (setq objNew (vla-insertblock space (vlax-3d-point base) "SH1" sca sca sca 0 ) ) (setq attNew (car (vlax-invoke objNew 'getattributes))) (vla-put-textstring attNew str) ) ) (vla-endundomark doc) (princ) ) HI ROY THIS ONE NOT WORKING HE CANT FIND THE FIELD Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 13, 2020 Share Posted September 13, 2020 First of all: please switch off CapsLock when writing forum posts. All caps texts are annoying. Are you testing the new code on the same machine and AutoCAD version as the previous code? Quote Link to comment Share on other sites More sharing options...
mousho Posted September 13, 2020 Author Share Posted September 13, 2020 2 hours ago, Roy_043 said: First of all: please switch off CapsLock when writing forum posts. All caps texts are annoying. Are you testing the new code on the same machine and AutoCAD version as the previous code? Sorry for the CapsLock i change the Code because it didnt work and use the nentsel that u advise there is the code that i use (defun C:MOLS (/ obj ) (vl-load-com) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (setq Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) ) ;(setq obj (car (entsel "\nSelect an Attributed Block: "))) (setq obj (car (nentsel "\nSelect an attribute: "))) (setq BASE (getpoint "\nSelect Base Point: ")) (setq YY (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa(vla-get-ObjectID (vlax-ename->vla-object obj))) ">%).TextString \\f \"%tc1\">%")) (command "_.Insert" "SH1" base (getvar "DIMSCALE") "" "" YY "") (prin1) ) ;END Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 14, 2020 Share Posted September 14, 2020 Just saying 'it does not work' is not going to get us anywhere. I have made an assumption regarding the source block that is selected. That assumption may be wrong. Please post a file with a block that the new code does not handle properly. Quote Link to comment Share on other sites More sharing options...
mousho Posted September 14, 2020 Author Share Posted September 14, 2020 29 minutes ago, Roy_043 said: Just saying 'it does not work' is not going to get us anywhere. I have made an assumption regarding the source block that is selected. That assumption may be wrong. Please post a file with a block that the new code does not handle properly. Hi roy I add the DWG with the block next to each block i write text the main goal is to read the middle block (that contain data from the below block) and make a new block (the top one) thx again for the help new block.dwg Quote Link to comment Share on other sites More sharing options...
Roy_043 Posted September 14, 2020 Share Posted September 14, 2020 The new code seems to work OK with your example DWG. The source block you select has a single attribute, and this matches my assumption. I can't think of a reason why the first version of my code works and the second version fails, other than that you are testing with different AutoCAD versions (32/64 bit). Quote Link to comment Share on other sites More sharing options...
mousho Posted September 14, 2020 Author Share Posted September 14, 2020 roi thx again and sorry for the bad english i success to fix it i used BASE_BB (entsel "\nSelect Base Point: ") obj (entnext (car BASE_BB)) 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.