Mr Minh Posted August 31, 2020 Posted August 31, 2020 Dear all, I need your help to get the lisp for summary of multi dims (1 dim or more) and this value (field) is replaced for existing text. Thank you so much for your help. - Mr Minh: minh.dxuan@gmail.com / +84 936 686 383 (Whatsapp / Viber / Wechat / Skypee) Quote
Mr Minh Posted August 31, 2020 Author Posted August 31, 2020 The dimension unit is mm and I need to replace the value of dimension to existing text with unit is meter with 02 number after decimal point. Many thanks. Quote
BIGAL Posted August 31, 2020 Posted August 31, 2020 Start with mtext and field option. The only hard part is must make each field value of the dim picked and using + to join as a string. Have adding attributes method similar for dims. I know adding dims exists did you google ? May not have field answer. eg 2 dims this is not tested something like this. "%<\\AcExpr %<\AcObjProp Object(%<\_ObjId 1953655456>%).Measurement >%+%<\AcObjProp Object(%<\_ObjId 1954502592>%).Measurement>% >% Quote
Mr Minh Posted September 1, 2020 Author Posted September 1, 2020 12 minutes ago, BIGAL said: Start with mtext and field option. The only hard part is must make each field value of the dim picked and using + to join as a string. Have adding attributes method similar for dims. I know adding dims exists did you google ? May not have field answer. eg 2 dims this is not tested something like this. "%<\\AcExpr %<\AcObjProp Object(%<\_ObjId 1953655456>%).Measurement >%+%<\AcObjProp Object(%<\_ObjId 1954502592>%).Measurement>% >% Many thanks Mr BIGAL. I am as the same as white paper with lisp. I only know how to load and run the lisp. Therefore, I don't know how to apply your suggestion. Quote
BIGAL Posted September 1, 2020 Posted September 1, 2020 Try this ; add dimension values put answer in mtext ; By alanH Aug 2020 (vl-load-com) (defun c:adddims ( / lst x obj objt str) (setq lst '()) (while (setq ent (entsel "\nPick dimension enter to finish")) (setq obj (vlax-ename->vla-object (car ent))) (setq lst (cons (strcat "%<\\AcObjProp Object(%<\\_ObjId " (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj :vlax-false) ">%).Measurement>%" ) lst )) ) (setq x -1) (setq str "%<\\AcExpr (") (repeat (- (length lst) 1) (setq str (strcat str (nth (setq x (+ x 1)) lst) "+")) ) (setq x (+ x 1)) (setq str (strcat str (nth x lst) ")>%")) (command "mtext" (getpoint "\nPick point" )(getpoint "\npick point") "a" "") (setq objt (vlax-ename->vla-object (entlast))) (vla-put-textstring objt str) (command "regen") (princ) ) (c:adddims) (princ "\nTo run again type adddims") Save to a file like adddims.lsp via notepad copy and paste, you can use Appload or drag and drop from windows explorer. 2 Quote
Mr Minh Posted September 4, 2020 Author Posted September 4, 2020 On 9/1/2020 at 7:56 AM, BIGAL said: Try this ; add dimension values put answer in mtext ; By alanH Aug 2020 (vl-load-com) (defun c:adddims ( / lst x obj objt str) (setq lst '()) (while (setq ent (entsel "\nPick dimension enter to finish")) (setq obj (vlax-ename->vla-object (car ent))) (setq lst (cons (strcat "%<\\AcObjProp Object(%<\\_ObjId " (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj :vlax-false) ">%).Measurement>%" ) lst )) ) (setq x -1) (setq str "%<\\AcExpr (") (repeat (- (length lst) 1) (setq str (strcat str (nth (setq x (+ x 1)) lst) "+")) ) (setq x (+ x 1)) (setq str (strcat str (nth x lst) ")>%")) (command "mtext" (getpoint "\nPick point" )(getpoint "\npick point") "a" "") (setq objt (vlax-ename->vla-object (entlast))) (vla-put-textstring objt str) (command "regen") (princ) ) (c:adddims) (princ "\nTo run again type adddims") Save to a file like adddims.lsp via notepad copy and paste, you can use Appload or drag and drop from windows explorer. Many thanks Mr BIGAL. Your lisp does not replace the value into existing text. And printing value = round(dimension value/1,000;2). Please help me. Quote
BIGAL Posted September 4, 2020 Posted September 4, 2020 Mtext supports fields not text. So if text would need extra code to make into MTEXT check txt2mtext help Replace (command "mtext" (getpoint "\nPick point" )(getpoint "\npick point") "a" "") (setq objt (vlax-ename->vla-object (entlast))) with (setq objt (vlax-ename->vla-object (car (entsel "Pick Mtext")))) e Quote
Mr Minh Posted September 12, 2020 Author Posted September 12, 2020 On 9/4/2020 at 11:01 AM, BIGAL said: Mtext supports fields not text. So if text would need extra code to make into MTEXT check txt2mtext help Replace (command "mtext" (getpoint "\nPick point" )(getpoint "\npick point") "a" "") (setq objt (vlax-ename->vla-object (entlast))) with (setq objt (vlax-ename->vla-object (car (entsel "Pick Mtext")))) e Many thanks BIGAL. I am white paper with code programming. I need your help. Please combine "replace" code into whole lisp for me. Best regards. 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.