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,216 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,217 Views
29 Replies
Replies (29)
Message 2 of 30

Sea-Haven
Mentor
Mentor

You can get the current value from a dynamic block as I can see shrink or stretch changes the values. You can use Lee-mac Dynamic Block functions, Dynamic Block Functions | Lee Mac Programming. So then add them up. 

 

For a block showing (12) 

(LM:GETDYNPROPS obj)
(("Distance1" . 3075.xxx-xxxxxxxx) ("Origin" 0.0 0.0 0.0) ("Spacing & no. of links" . "( ) 150") ("Bar Size" . 10.0) ("Origin" 1732.xxx-xxxxxxxx 511.194790271098 1.02868241965889e-05) ("Distance3" . 2108.xxx-xxxxxxxx) ("Text Location" . 6.15727179154933) ("Origin" -1.17073068395257e-06 100.000000122702 0.0) ("Text Angle" . 3.14159258347001) ("Origin" 960.222686269668 242.xxx-xxxxxxxx 1.02868241965889e-05))
: (/ 3075 150)
20
: (/ 2108 150)
14 is correct answer 14-2 ie edge gap.

So still confused getting the field string showed get a length of an object, so how is this relevant to any of the other objects making the block. Or the dynamic properties. 

"\\pxqr;{\\T0.95;(%<\\AcObjProp.16.2 Object(%<\\_ObjId 1986975136 0>%).Length \\f \"%lu2%pr0%ct8[0.006667]\">%)}"

 

0 Likes
Message 3 of 30

skchui6159
Advocate
Advocate

Sorry, I am not the creator of block. Only get attribute value of block and Mtext/ text, then update the Mtext eg. "16"ET16-200... update 16 is OK.

0 Likes
Message 4 of 30

skchui6159
Advocate
Advocate

Can you provide some reference example/ location for me to write the lisp? Thank you.

0 Likes
Message 5 of 30

skchui6159
Advocate
Advocate
(defun LM:getdynprops (blk)
  (mapcar '(lambda (x) 
              (cons (vla-get-propertyname x) (vlax-get x 'value)))
          (vlax-invoke blk 'getdynamicblockproperties)))
 
(defun c:GetAllDynamicProperties ()
  (setq blk "DynB-CalBarNo_1_50_ET")
(setq ss (ssget (list '(0 . "INSERT") (cons 2 (strcat blk ",`*U*")) '(66 . 1))))
  (if ss
    (progn
      (setq blk (vlax-ename->vla-object (ssname ss 0)))
      (setq properties (LM:getdynprops blk))
      (foreach prop properties
(princ (strcat "\nProperty: " (car prop) ", Value: " (cdr prop))) ;
        ;(princ (strcat "\nProperty: " (car prop) ", Value: " (rtos (cdr prop) 2 2)))
      )
    )
    (princ "\nNo dynamic block selected.")
  )
)
I try to get the prop value of the block, anyone can tell me why go error?
0 Likes
Message 6 of 30

Moshe-A
Mentor
Mentor

@skchui6159  hi,

 

The error arises cause the data returns from (setq properties (LM:getdynprops blk)) is mixed.

e.g string, reals, list (points) and the (strcat) function accept only strings.

 

would you provide an example of what you want to do here?

post a sample dwg with before and after state.

 

Moshe

 

0 Likes
Message 7 of 30

skchui6159
Advocate
Advocate

skchui6159_1-1734704201772.png

skchui6159_2-1734704367954.png

 

@Moshe-A Hi, Greeting. I want to add all number of in the blanket (integer) in the block/Mtext/text and then update the no. of rebars of the orginal text (left hand side before the text of "ET" and "T") after select the object.

 I use the above lisp try to extracted the prop value. (It is my proposed step 1...)

 

0 Likes
Message 8 of 30

Sea-Haven
Mentor
Mentor

Skhui696 is trying to add all the displayed numbers some are fields some are plain mtext. If its just make a new mtext then its sum the values, if its can change the values so final text is updated then a field sum made up of all objects is required. The issue I was having is that the individual dynamic block has a field that uses ".length" but the objects dont appear to have any dynamic parameters matching that length. So I could not even get the resulting field value eg 12. Its buried deep inside the dynamic block. So any ideas on how to get that value then summing them is the easy part.

 

ps I did manage to get the field string but I used nentsel to get at it. 

0 Likes
Message 9 of 30

skchui6159
Advocate
Advocate

I have an idea. Can use somewhere to copy and paste then explode. Also make them in a group, get the value? Final, erase the new items? But how the lisp can get the prop value of the block.

0 Likes
Message 10 of 30

ec-cad
Collaborator
Collaborator
Accepted solution

Here's my 5 cents. Yes, Copy, Explode, get sum, update original, remove copy..it's all here.

Try this one. Tested on your sample drawing.

Load or drag/drop into your drawing. Function call is COUNT. Pick a window around your layout,

then, pick the MTEXT at the far end.

Note: you cannot have items to the right of the rebar layout ~ 16000 units, that's where the

program makes a copy. It also makes a Layer called "TEMP". You may want to remove that.

 

 

Have fun with it.

ECCAD

0 Likes
Message 11 of 30

ec-cad
Collaborator
Collaborator

Guys,

I tried a few hours to dig into the Dynamic block to grab the MTEXT. No go on my part.

I tried all the (assoc 330 / (assoc 360's - kept going back to the Block. Shows something in

XDICTIONARY ? Whatever that is. Gave up, made a Lisp to grab the rebar layout, copy / explode, remove

so it would surface those burried MTEXTS. Why are they burried so deep that I can't seem to get at them

is a mistery. Maybe someone here can explain how to get to them...

ECCAD

0 Likes
Message 12 of 30

skchui6159
Advocate
Advocate

@ec-cad Thank you very much of your lisp!

😁Sorry, a more question. Sometime, I select a bit more of the object, the line below the text will also erased. Could it can be solve? 

 

The lisp is Good! Thanks.

0 Likes
Message 13 of 30

skchui6159
Advocate
Advocate

@ec-cad A further question, sometime the block should be horizontal as the rebar have 2 way direction like that, it can also include that case?

skchui6159_1-1734856750485.png

 

 

0 Likes
Message 14 of 30

Moshe-A
Mentor
Mentor

@skchui6159  hi,

 

Yesterday i have spent the whole day (from 9:00 to 24:00) trying to figure this out and i think

i crack it  😀  (no very easy i admit) but it is still not finished (it will tonight) but i have two question for you:

 

1. Why do you use mtext and not keep using the dynamic block? it will be much easier if it will be not mixed.

2. the dynamic block is very sophisticated one (btw: its it yours?) contain about 20 visibility states, on your sample you use "() 150".

    if you use others, it would help if you post sample.

 

Moshe

 

 

0 Likes
Message 15 of 30

skchui6159
Advocate
Advocate

@Moshe-A This block not mine... But I need use it for working (Question 2)...Thank you for your help! Be relax.

For the question 1, because I think the dynamic block can not support multiple object in different distance to show the result. In the single result, the visibilty show the result directly (in custom spacing set it to eg. 225 c/c it shows 2T20-225...) .  I think using lisp to select dynamic block to find the result is very complex (may be no solution....😅).

 

 

0 Likes
Message 16 of 30

Moshe-A
Mentor
Mentor

Yes there will be a solution tonight or max tomorrow

 

 

0 Likes
Message 17 of 30

skchui6159
Advocate
Advocate

@Moshe-A Thank you for help! For my level, I think that may be I can not get any value of the block....😂

0 Likes
Message 18 of 30

Moshe-A
Mentor
Mentor

@skchui6159 wrote:

@Moshe-A Thank you for help! For my level, I think that may be I can not get any value of the block....😂


to use the block you can be at user normal level (you should explore it a bit)

but if you do not plan to use the block, there is no point for my lisp

 

 

0 Likes
Message 19 of 30

skchui6159
Advocate
Advocate

@Moshe-A I use the this block for calulate the rebar number lots of time (user level). I know there are different visibilty mode in block. In multiple object, I can just use visibilty mode (eg.150) for my works. There are lot of visibilty mode... Single calculation of a rebar spacing, the dynamic blk can help. In the view of block properties, I can find the value of grid distance..., but I can not find the information of number of rebar...😅

 

0 Likes
Message 20 of 30

Moshe-A
Mentor
Mentor

@skchui6159 wrote:

@Moshe-A I use the this block for calulate the rebar number lots of time (user level). I know there are different visibilty mode in block. In multiple object, I can just use visibilty mode (eg.150) for my works. There are lot of visibilty mode... Single calculation of a rebar spacing, the dynamic blk can help. In the view of block properties, I can find the value of grid distance..., but I can not find the information of number of rebar...😅

 

Ya, if we could talk to the author of this block, it could save us a lot of time but since this is not possible you have to explore.

you could modified it to meet your needs though. if "() 150" serve you, then their is a place for the lisp but as i said, consider avoiding

using mtext cause the beauty of the block is the field in mtext that attached to a polyline which result the length according to stretching of the rebar.

 

 

 

 


 

0 Likes