Sum of dynamic block attributes and Text or MText with above a line and update the Value with Selection

Sum of dynamic block attributes and Text or MText with above a line and update the Value with Selection

skchui6159
Advocate Advocate
2,227 Views
29 Replies
Message 1 of 30

Sum of dynamic block attributes and Text or MText with above a line and update the Value with Selection

skchui6159
Advocate
Advocate

Is possible on lisp to sum up the value and self update the MText of the no. of rebar of the dynamic block in above a line with selection? If there are no MText, no need to update.

0 Likes
Accepted solutions (2)
2,228 Views
29 Replies
Replies (29)
Message 21 of 30

skchui6159
Advocate
Advocate

Sorry, i am apologize that I got the wrong way to do this task.😔 I need to try to modify the block can measure multiple distance and resulting the rebar numbers. Thanks for your advice!

0 Likes
Message 22 of 30

ec-cad
Collaborator
Collaborator

Count.lsp will work for a single set of either Vertical or Horizontal items.

Whatever is included in the 'Crossing' of the 2 points you pick will be copied in the

Horizontal direction. It adjusts the target points, based on original X,Y of each point chosen.

So, if the original info is oriented Horizontal - you get a copy that's Horizontal, and if the

original info is oriented Vertical - you get a copy that's Vertical.

You can include any 'lines' or points, circles, whatever is in the Crossing Window picks.

The program just makes a copy to the right, explodes items if they are 'Inserts,' (Blocks) leaves the

rest as it is. Exploding those Blocks, surfaces the embedded MTEXT's so they can be examined.

Then, the program changes the Properties of those items to be on Layer Temp. Next, it gathers

only the MTEXT items  on Layer Temp, gets their text value, looks for a "(", and gets the numbers inside

the ( ), makes a sum of the (atoi value), string to integer. Once done with that, just removes the

items from the Temp layer, and zooms previous so you can pick the MTEXT item to update.

So, bottom line, should work for either Vert or Horiz.

ECCAD

0 Likes
Message 23 of 30

ec-cad
Collaborator
Collaborator
Accepted solution

For this sample drawing. You have the Vertical samples (to the right) of the Horizontal samples.

Since the Lisp has a 'constant' distance to the right that it copies to, you may need to increase

the distance to say, 32000 rather than the 16000 presently.

Try this on your new sample drawing with both Vertical and Horizontal layouts.

 

ECCAD

0 Likes
Message 24 of 30

Sea-Haven
Mentor
Mentor

@ec-cad "increase the distance" use (getvar 'extmax) then add a X or Y value to max, then you know that point so do the edits then copy back, have used this for this type of task. The copied objects will be outside the extmax.

0 Likes
Message 25 of 30

skchui6159
Advocate
Advocate

Thank you very much! The lisp works great on vertical and horizontal item!

0 Likes
Message 26 of 30

ec-cad
Collaborator
Collaborator

Sea-Haven,

Great idea. Here's the resultant lisp with (extmax).

ECCAD

 

0 Likes
Message 27 of 30

Sea-Haven
Mentor
Mentor

Happy to help.

 

This may be the path to a solution, bit busy at moment its Christmas. A pick pick pick answer.

 

(defun c:wow ( / obj1 obj2 str txt)
(setq obj1 (vlax-ename->vla-object (car (nentsel "\nPick source text "))))
(setq obj2 (vlax-ename->vla-object (car (entsel "\nPick destination text "))))
(setq id (vlax-invoke-method (vla-get-Utility  (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj1 :vlax-false))
(setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " id ">%).TextString>%"))
(vlax-put obj2 'textstring str)
(princ)
)

 

I have daisy chain attributes summing them to a field, so maybe can get the ID of the bar number. So method would be pick+pick+pick. 

0 Likes
Message 28 of 30

skchui6159
Advocate
Advocate

@ec-cad @Sea-Haven Thank you very much! I have update the .LSP with "Mtext" and "Text" version. Added Picking mode. Finally will zoom to the designate location.

0 Likes
Message 29 of 30

skchui6159
Advocate
Advocate

Good idea, Thank you very much!

0 Likes
Message 30 of 30

skchui6159
Advocate
Advocate

This method is good! The running time of your lisp is very fast.  

0 Likes