How can I determine if a block definition is scaled uniformly?

How can I determine if a block definition is scaled uniformly?

jamieq
Collaborator Collaborator
1,023 Views
5 Replies
Message 1 of 6

How can I determine if a block definition is scaled uniformly?

jamieq
Collaborator
Collaborator

I have a program that inserts a block. Simple enough. However, the block may or may not be scaled uniformly. That means the insert command may or may not ask for a Y scale. This causes problems with the program. Is there a way to determine if a block definition is scaled uniformly? Then I can run the block through a check while inserting. So far all I can find from lots of searching is (vla-get-BlockScaling blk), but that just doesn't exist in AutoCAD 2016. There appears to just be no BlockScaling property or command. But there has to be somewhere to get that piece of data, as AutoCAD uses it. 

0 Likes
Accepted solutions (2)
1,024 Views
5 Replies
Replies (5)
Message 2 of 6

jamieq
Collaborator
Collaborator
Accepted solution

Found it. The BlockScaling property is a property the soft-pointer handle, not the block definition.

 

(setq blk (vlax-ename->vla-object (cdr (assoc 330 (entget (tblobjname "block" [Block Name]))))))

(vla-get-BlockScaling blk)

 

0 = acAny

 1 = acUniform

 

That information is NOT readily available anywhere, or even remotely available. 

0 Likes
Message 3 of 6

jamieq
Collaborator
Collaborator
Accepted solution

Turns out I had solved this a long time ago in a different program I wrote. Instead of inserting with (command "-insert" blk pause 1 pause) or (command "-insert" blk pause 1 1 pause) depending on scale uniformity, I used (command "-insert" blk "S" 1 pause pause). This inserts the block with X, Y , and Z scales all set to 1. Much cleaner method. 

0 Likes
Message 4 of 6

CodeDing
Advisor
Advisor

@jamieq,

 

Is there a good argument for not trying to alternatively use ENTMAKEX? This is useful for me when not having to worry about scaling. Also it returns entity name and avoids using (entlast).

;2 - Block Name; 10 - Insertion Point
(entmakex (list (cons 0 "INSERT") (cons 2 "MyBlock") (cons 10 (list 0 0 0)))))

Best,

~DD

0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant

@CodeDing wrote:
.... Is there a good argument for not trying to alternatively use ENTMAKEX? ....

 

If you want to visually drag it into place, and especially if you may want to give it a non-zero rotation angle, those would be pretty good arguments for a (command) function with some pauses.  [Note that their snippet in Message 3 does not build in or accept the default zero rotation, but has a pause  for rotation, meaning presumably the desired rotation would vary, while your suggestion doesn't account for it at all.]

Kent Cooper, AIA
0 Likes
Message 6 of 6

CodeDing
Advisor
Advisor

@Kent1Cooper,

 

Those would certainly be good arguments against. I guess I enjoy the idea of avoiding (entlast) (whether that is or is not relevant in this case) and want others to know that there are certainly many ways to accomplish similar tasks in AutoLISP. 

 

Always appreciate your insight Kent.

 

Best,

~DD