Update a Dimension in Dynamic Block

Update a Dimension in Dynamic Block

SAPER59
Advocate Advocate
2,288 Views
11 Replies
Message 1 of 12

Update a Dimension in Dynamic Block

SAPER59
Advocate
Advocate

I have a dynamic block to which when I set a dynamic parameter for width and height, it adopts the new values changin the shape, but it has dimensions associated that does not change, but if I do it manually  selecting it  and streching, the dimension values are updated.

What can be done in Visual Lisp to have this parameter updated when modifiying the dynamic values

 

Thanks

0 Likes
2,289 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable

When Selecting the objects for stretching, Include the dimensions also.

If you Includes the  dimensions for stretching, it no need to be associate with object.

 

If you excludes the dimensions from selection for stretching, it must be associate with the object.

Check whether it is Associate or not.

 if not, go to Options---> User Preferences, and check the box of "Make new dimensions associative" 

 

It may help you

 

STM

0 Likes
Message 3 of 12

hmsilva
Mentor
Mentor

@SAPER59 wrote:

I have a dynamic block to which when I set a dynamic parameter for width and height, it adopts the new values changin the shape, but it has dimensions associated that does not change, but if I do it manually  selecting it  and streching, the dimension values are updated.

What can be done in Visual Lisp to have this parameter updated when modifiying the dynamic values

 

Thanks


Weird, the block behavior should be the same, using a code, or manually stretch.
Using properties palette and changing the parameter value, the dimension values are updated?

 

If possible, attach the block...

Henrique

EESignature

0 Likes
Message 4 of 12

SAPER59
Advocate
Advocate

The point is that the real measure when set the new dynamic value is right but the dimension value shown is not updated, even with vla-update object, but if you close and reopen the DWG they are updated

I found that the same problem was found and solved in ObjectARX in http://adndevblog.typepad.com/autocad/2012/09/updating-dimensions-associated-with-a-dynamic-block.ht... but can not access to this in Visual Lisp with ActiveX (at least I can not)

0 Likes
Message 5 of 12

SAPER59
Advocate
Advocate

I attach the DWG and the function and you will see that the shape changes, but not the DIM, but it does if you click on the arrow and modify manually

 

 

 

(vl-load-com)

 

(defun DynamicProps (ename propname value / obj prpL cla cll prp return)
(setq obj (if (= (type ename) 'VLA-OBJECT)
ename
(vlax-ename->vla-object ename)
)
)
(if (eq "AcDbBlockReference" (vla-get-objectname obj))
(progn
(setq prpL (vlax-invoke obj 'getdynamicblockproperties))
(setq return
(if (setq
prp (vl-remove-if-not
(function (lambda (x)
(= (vlax-get-property x 'PropertyName) propname)
)
)
prpL
)
)
(mapcar (function
(lambda (v)
(if (and (/= value nil)
(vlax-property-available-p v 'Value)
(/= (type value) 'list)
)
(progn

(vlax-put-property v 'Value value)
(vla-update obj)
)
)
(if (and (vlax-property-available-p v 'AllowedValues)
(vlax-get v 'AllowedValues)
)
(list (vlax-get v 'Value) (vlax-get v 'AllowedValues))
(vlax-get v 'Value)
)
)
)
prp
)
(mapcar (function
(lambda (v)
(list (vla-get-propertyname v) (vlax-get v 'Value) v)
)
)
prpL
)
)
)
)
)
(princ)
return
)


(DynamicProps (car(entsel)) "W2" 20.0)

0 Likes
Message 6 of 12

hmsilva
Mentor
Mentor

Hi SAPER59,

the code works as expected, you'll have to add a REGEN to update the dimension... 😞

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 7 of 12

SAPER59
Advocate
Advocate

Thanks, but REGEN update ONLY if you have the original block.

Make a copy of the object (what is my case bacause I create an spetial array of them) and then change the dynamic value

 At least in my case does not update.

Maybe there's a variable to set??

0 Likes
Message 8 of 12

hmsilva
Mentor
Mentor

SAPER59 wrote:

Thanks, but REGEN update ONLY if you have the original block.

Make a copy of the object (what is my case bacause I create an spetial array of them) and then change the dynamic value

 At least in my case does not update.

Maybe there's a variable to set??


Hi SAPER59,

the problem was in the block, I made a new selection in each action selection set.

 

Try the attached one.

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 9 of 12

SAPER59
Advocate
Advocate

Thank you Henrique.

Now it works perfectly.

I almost became mad trying to find the problem.

Just one question, what was the problem in the block, what did you change?

Just to know and know what to do it it happen again in another situation

 

Thanks

 

 

0 Likes
Message 10 of 12

hmsilva
Mentor
Mentor

@SAPER59 wrote:

Thank you Henrique.

Now it works perfectly.

I almost became mad trying to find the problem.

Just one question, what was the problem in the block, what did you change?

Just to know and know what to do it it happen again in another situation

 

Thanks


You're welcome, SAPER59

Probably, the dimensions were added after setting the action and the action selection set created...

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 11 of 12

SAPER59
Advocate
Advocate

I will have a look

Thanks again Henrique

0 Likes
Message 12 of 12

ehsan_bahrani
Enthusiast
Enthusiast

i have the same problem with c# .net autocad api, i try everything but there is no luck, manually it works fine, but when using the code to create new blockreference and set new parameter the associated dimension not update automatically.

0 Likes