Jump to content

Need your help about "Dimsum of Multi Dims to Field"


Recommended Posts

Posted

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)

Posted

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.

Posted

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>% >%

 

 

 

 

 

 

Posted
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.

Posted

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.

  • Like 2
Posted
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.

Posted

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

Posted
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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...