Author Topic: Move Method  (Read 6810 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Move Method
« on: November 24, 2005, 04:00:01 AM »
For anyone interested.

Following on From Micks Topic : Moving entities with code in different ucs..

If we were to build a Mover method in a Utility class :-

Would you expect the points passed in to be WCS
or in UCS with the points to be translated to WCS in the Method.

Another option I s'pose would be to Override the Method .. something like the outline posted ....

and :
Would you expect the Method to return a Boolean indicating Sucess or otherwise ? ?

Any comments ? ?

Code: [Select]
#region using declarations
// ..
// ..
#endregion



namespace kwbTesting
{
public class Utility
{
public static void Mover(Entity ent, Point3d fromPoint, Point3d toPoint)
{
Utility.Mover(ent.ObjectId, fromPoint, toPoint);
}
public static void Mover(Entity ent, Point3d fromPoint, Point3d toPoint, Matrix3d TransformationMatix)
{
Utility.Mover(ent.ObjectId, fromPoint, toPoint, Matrix3d TransformationMatix);
}

//------------------
public static void Mover(ObjectId id, Point3d fromPoint, Point3d toPoint)
{
// Default Method assumes to WCS
// so determine Matix3D to WCS
Matrix3d TransformationMatix = // bla bla ;
Utility.Mover(id, fromPoint, toPoint, TransformationMatix);

}
public static void Mover(ObjectId id, Point3d fromPoint, Point3d toPoint, Matrix3d TransformationMatix)
{
// Do the MOVE Mojo Here for ALL Methods
}
//------------------
}
}


edit due to fat fingers :
« Last Edit: November 24, 2005, 04:29:22 AM by Kerry Brown »
kdub in one timeline.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<-

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Move Method
« Reply #1 on: November 24, 2005, 06:44:12 AM »
G'day kerry, some comments from my quick glance:

1. If you're forwarding on calls to your overloaded 'mover' function that takes an objectid, make those functions private - the outside world doesn't need to see them.

2. If you're passing in 'Entity ent' why pass the objectid to the forwarded functions? Pass the 'ent' reference directly.

Cheers,
Glenn.
Me

MickD

  • King Gator
  • Posts: 3520
  • (x-in)->[process]->(y-out)
Re: Move Method
« Reply #2 on: November 24, 2005, 06:51:29 AM »
For anyone interested.

Following on From Micks Topic : Moving entities with code in different ucs..


Would you expect the points passed in to be WCS
or in UCS with the points to be translated to WCS in the Method.

Kerry,
from my experience the points, regardless of ucs, are returned in wcs coordinates. This means you need to get the points, get the current ucs and build a matrix of the wcs to ucs to transform the points to the current ucs.
This is a big difference to the COM api where the returned point is already in the current ucs, the hard work is done for you. In arx all entities you create are drawn in wcs and you have to transform them into place.

I dont think you need to overload it as such, I think you just need to know the 2 points picked by the user. Things like current ucs etc. can be accessed from the working db, perhaps that can be passed in as well. The return I would use would be a 'Matrix3d' then you simply  'ent.TranformBy(mat)'.

Jim Awe's code is probably the best example for this, his 'GetWcsToUcs' matrix method is basically part of what I posted and in its 'method' format is well worth while as a utility.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

"The E in Javascript stands for 'easy'." Florin Pop tweet

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Move Method
« Reply #3 on: November 24, 2005, 07:42:49 AM »
DOH !!
That's what I get for posting after dark when there is a bottle on the bench.    :oops:

I'll revisit the post when the wetware is working ...


Glenn,
I was considering providing the option for passing in either the Entity or the objectId from the caller.
I'll have to check for myself, but I read your post to mean that using Entity may be the more frequently used.

kdub in one timeline.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<-

MickD

  • King Gator
  • Posts: 3520
  • (x-in)->[process]->(y-out)
Re: Move Method
« Reply #4 on: November 24, 2005, 08:08:54 PM »
DOH !!
That's what I get for posting after dark when there is a bottle on the bench. :oops:
...

heh, don't worry Kerry, I had to check this morning that what I wrote was legible myself  :-o

It was Thirsty Thursday afterall  :laugh:
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

"The E in Javascript stands for 'easy'." Florin Pop tweet

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Move Method
« Reply #5 on: November 26, 2005, 05:18:25 AM »
[............. from my experience the points, regardless of ucs, are returned in wcs coordinates. This means you need to get the points, get the current ucs and build a matrix of the wcs to ucs to transform the points to the current ucs.

heh, Mick ;
tell me this again, in a different way, cause I can't agree with it.

Selected points seem to be  returned relative to the UCS origin.

kdub in one timeline.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<-

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Move Method
« Reply #6 on: November 26, 2005, 06:45:06 AM »
Mick,

If you're using GetPoint off the Editor, it wraps acedGetPoint, which DEFINATELY returns points in the current UCS.

Kerry,

As far as passing the objectId or a reference to an entity, the reference would be preferable in my opinion.
If you pass the reference, it AT LEAST has to be open for read and you can check this, whereas passing an objectid,
you would then have to open it up thru a transaction to do your mojo....does that make sense?????

If you've got a reference to an entity, pass it - it's easier imo.

Cheers,
Glenn.
Me

MickD

  • King Gator
  • Posts: 3520
  • (x-in)->[process]->(y-out)
Re: Move Method
« Reply #7 on: November 27, 2005, 04:11:40 PM »
[............. from my experience the points, regardless of ucs, are returned in wcs coordinates. This means you need to get the points, get the current ucs and build a matrix of the wcs to ucs to transform the points to the current ucs.

heh, Mick ;
tell me this again, in a different way, cause I can't agree with it.

Selected points seem to be returned relative to the UCS origin.



Yes Kerry and Glenn, you're both right, it's been a long weekend  :oops:

A far better explanation would have been they are 'treated' as world coordinates when using them on objects in the db. All though the points are relative to the current ucs, when applied to an object for a transformation they are 'ucs neutral' for want of a better term. ie. a point with the value (5,7,0) in the current ucs is quite different to a point with the same values in world, the returned points will require a transformation (back to world coords) before using them.
Hope that makes more sense.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

"The E in Javascript stands for 'easy'." Florin Pop tweet