Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

29 REPLIES 29
SOLVED
Reply
Message 1 of 30
skchui6159
1115 Views, 29 Replies

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

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.

29 REPLIES 29
Message 21 of 30
skchui6159
in reply to: Moshe-A

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

Message 22 of 30
ec-cad
in reply to: skchui6159

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

Message 23 of 30
ec-cad
in reply to: skchui6159

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

Message 24 of 30
Sea-Haven
in reply to: skchui6159

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

Message 25 of 30
skchui6159
in reply to: ec-cad

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

Message 26 of 30
ec-cad
in reply to: Sea-Haven

Sea-Haven,

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

ECCAD

 

Message 27 of 30
Sea-Haven
in reply to: skchui6159

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. 

Message 28 of 30
skchui6159
in reply to: ec-cad

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

Message 29 of 30
skchui6159
in reply to: Sea-Haven

Good idea, Thank you very much!

Message 30 of 30
skchui6159
in reply to: Sea-Haven

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report