LISP to keep the rotation of dynamic blocks and make them static

LISP to keep the rotation of dynamic blocks and make them static

karpki
Advocate Advocate
3,089 Views
22 Replies
Message 1 of 23

LISP to keep the rotation of dynamic blocks and make them static

karpki
Advocate
Advocate

Hi, Friends,

 

There are dynamic blocks with the only rotation function in the drawing, see sample in the attachment.

The task is to make them static and keep angled as they are.

So steps probably should be like these

1. to get the list of rotation angles of blocks XX selecting one of them. Selection is needed cause there can be a range of different blocks.  

I'm not sure but may be by kind of this procedure 

(setq obj (car (vl-remove-if-not '(lambda (x) (= (vla-get-propertyname x) "_Angle1"))
(vlax-safearray->list(vlax-variant-value (vla-getdynamicblockproperties obj)))))

 

2. to edit the block XX by killing dynamic functions f.e. by this list of commands _bedit;ai_selall;_copybase;0;0;delete;_pasteclip;0;_bclose;;

 

3. to rotate each of XX blocks by the angle taken in p. 1

this is the most hard part I think 

 

Does it look possible ? Do you have kind of ready lisp or suggestions ?

0 Likes
Accepted solutions (2)
3,090 Views
22 Replies
Replies (22)
Message 21 of 23

pbejse
Mentor
Mentor

@karpki wrote:

First attempt was with the "ssget mistake"

The "I" is ssget is for Implied selection (objects selected while PICKFIRST is in effect). 

The "_" tells AutoCAD to use the English version of the command for international versions of AutoCAD.

Necessary for international versions of Autocad but still works on english version nevertheless. Therefore not a mistake.

 


@karpki wrote:

But after killing blocks, they are not at the right angels - all zeroes.


Not on my planet | 

Notonthisplanet.png

 


@karpki wrote:

How to rotate them back according dynamicblockproperty values taken in step 2 ?


Have no reason to do that on my end.

 

You need to test the code line by line and see if thius line evaluates to T

(setq dp (vl-some '(lambda (d)
		 (if (eq "Угол1" (vla-get-PropertyName d))
		 )
	       )
	      (vlax-invoke e2 'getdynamicblockproperties)
     )
)
; Угол1 is a dynamic function name in my ACad.

I definitely cannot check it here. 

Run this bit on an undead Dynamic block, it will show you the propertyname that the program recognize. use that vl-some condition and see how it goes.

(foreach itm (vlax-invoke
	       (vlax-ename->vla-object (Car (entsel)))
	       'getdynamicblockproperties
	     )
  (print
    (list (vla-get-propertyname itm) (vlax-get itm 'Value))
  )
  (princ)
)

 

HTH

0 Likes
Message 22 of 23

karpki
Advocate
Advocate

OK! It looks like Acad localization problem. Will soon install english one and then will check this.

 

So accepted finally!

 

Thanks a lot!

0 Likes
Message 23 of 23

karpki
Advocate
Advocate

Checked with the ACad2021 English - works perfect

Ru version - doesn't work

Ru version + ENG lang pack - doesn't work

 

I don't know if anybody else needs it 

Because it is quite specific

But the code without unneeded comments is attached

0 Likes