implement the same function as the command ‘chspace’ problem

implement the same function as the command ‘chspace’ problem

swaywood
Collaborator Collaborator
353 Views
3 Replies
Message 1 of 4

implement the same function as the command ‘chspace’ problem

swaywood
Collaborator
Collaborator

Hi,

I posted a post a few days ago. Here is the link.

https://forums.autodesk.com/t5/net/how-to-use-code-to-implement-the-same-function-as-the-command/td-...
In most cases, the code in it can achieve the expected effect, but there are also exceptions, such as the dwg I uploaded, the entities did not come to the correct location after executing the command.

swaywood_0-1676347359710.png

 

0 Likes
Accepted solutions (2)
354 Views
3 Replies
Replies (3)
Message 2 of 4

swaywood
Collaborator
Collaborator
Accepted solution

Sorry, I made a mistake. I changed the order of the two matrix.

The code of link is correct.

//wrong
var WCS2PSDCS1 = vp.WCS2DCS() * vp.DCS2PSDCS();
//correct
var WCS2PSDCS2 = vp.DCS2PSDCS() * vp.WCS2DCS();

0 Likes
Message 3 of 4

_gile
Consultant
Consultant
Accepted solution

Hi,

 

Matrix multiplication is not commutative.

Matrix1 * Matrix2 means: apply Matrix1 to Matrix2.

 

entity.TransformBy(vp.DCS2PSDCS() * vp.WCS2DCS());

can be written in a sequential way:

entity.TransformBy(vp.WCS2DCS());
entity.TransformBy(vp.DCS2PSDCS());

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 4

swaywood
Collaborator
Collaborator

Thank you very much. Yes, the second way is easier to understand.

0 Likes