Author Topic: acedTrans to .NET  (Read 4736 times)

0 Members and 1 Guest are viewing this topic.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
acedTrans to .NET
« on: February 24, 2008, 06:06:59 AM »
I'm brain dead, and have an early morning tomorrow
.. and since it's Sunday morning for some ...

The ARX docs for acedTrans reads
Quote
int acedTrans(
    const ads_point pt,
    const struct resbuf * from,
    const struct resbuf * to,
    int disp,
    ads_point result
);
File
acedads.h

Parameters
Parameters  Description 
const ads_point pt  Point to be translated, interpreted as either a three-dimensional point or a three-dimensional displacement vector depending on the value of disp 
const struct resbuf * from  Coordinate system in which pt is expressed 
const struct resbuf * to  Coordinate system in which result is expressed 
int disp  If nonzero, pt is treated as a displacement vector; otherwise, it is treated as a point 

Returns
Result of the translation

Description
Translates a point or a displacement from one coordinate system into another.

The from and to arguments can specify a coordinate system in any of the following ways:


An integer code (restype == RTSHORT) that specifies the WCS, current User Coordinate System (UCS), or current Drawing Coordinate System (DCS) (of either the current viewport or paper space), as described in the following table.
An entity name (restype == RTENAME), as returned by one of the entity name or selection set functions. This specifies the ECS of the named entity.
For planar entities, the ECS can differ from the WCS. If the ECS does not differ, conversion between ECS and WCS is an identity operation.


A 3D extrusion vector (restype == RT3DPOINT). This is another method of specifying an entity's ECS.
Extrusion vectors are always represented in World coordinates; an extrusion vector of (0,0,1) specifies the WCS.

Coordinate system codes:

 

0  World (WCS) 
1  User (current UCS) 
2  Display:DCS of current viewport when used with code 0 or 1DCS of current model space viewport when used with code 3 
3  Paper space DCS (PSDCS; used only with code 2) 

Warning The paper space DCS (PSDCS) can be transformed only to or from the model space DCS. Therefore, if the from argument equals 3, the to argument must equal 2, and conversely.

If acedTrans() succeeds, it returns RTNORM; otherwise, it returns an error code. When acedTrans() fails, it sets the system variable ERRNO to a value that indicates the reason for the failure.


So I tried this
Code: [Select]
code.redundant.delete();

and called it like this

Code: [Select]
 
code.redundant.delete();

but the results seem wacky ..... Anyone want to play with it while I sleep ??
« Last Edit: February 29, 2008, 09:30:51 PM by Kerry Brown »
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<--

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: acedTrans to .NET
« Reply #1 on: February 29, 2008, 09:28:31 PM »
Modified the code from the first post.

In the Library : 
Code - C#: [Select]
  1.         // // CodeHimBelongaKwb  Mar 2008
  2.  [DllImport("acad.exe", CallingConvention=CallingConvention.Cdecl)]
  3.         private static extern int acedTrans(
  4.             double[] point,
  5.             IntPtr fromResbuf,
  6.             IntPtr toResbuf,
  7.             int displacement,
  8.             double[] result
  9.         );
  10.         /// <summary>
  11.         ///
  12.         /// </summary>
  13.         public enum CoOrds
  14.         {
  15.             WCS = 0,
  16.             UCS,
  17.             DisplayDCS,
  18.             PaperSpaceDCS
  19.         }
  20.         /// <summary>
  21.         ///
  22.         /// </summary>
  23.         /// <param name="PtToTranslate"></param>
  24.         /// <param name="from"></param>
  25.         /// <param name="to"></param>
  26.         /// <returns></returns>
  27.         public static AcGe.Point3d TranslateCoordinates(this AcGe.Point3d PtToTranslate,
  28.                                                                     CoOrds from,
  29.                                                                     CoOrds to)
  30.         {
  31.             AcDb.ResultBuffer fromResbuf = new AcDb.ResultBuffer(new AcDb.TypedValue(0x138b, from));
  32.             AcDb.ResultBuffer toResbuf = new AcDb.ResultBuffer(new AcDb.TypedValue(0x138b, to));
  33.             double[] result = new double[] { 0, 0, 0 };
  34.  
  35.             acedTrans(PtToTranslate.ToArray(),
  36.                 fromResbuf.UnmanagedObject,
  37.                 toResbuf.UnmanagedObject,
  38.                 0,
  39.                 result
  40.             );
  41.             return new AcGe.Point3d(result);
  42.         }

The calling routine :
Code - C#: [Select]
  1.         // // CodeHimBelongaKwb  Mar 2008
  2.         [AcRx.CommandMethod("TranslatePoint")]
  3.         static public void TestPointTranslation()
  4.         {
  5.             // AcDb.Database db = AcDb.HostApplicationServices.WorkingDatabase;
  6.             AcEd.Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
  7.  
  8.             AcGe.Point3d basePoint = new AcGe.Point3d();
  9.  
  10.             ed.WriteMessage("\n Translate Point 0,0,0 from UCS to WCS : "
  11.                  + basePoint.TranslateCoordinates(
  12.                       dbExtensions.CoOrds.UCS,
  13.                       dbExtensions.CoOrds.WCS ).ToString());
  14.  
  15.             ed.WriteMessage("\n Translate Point 0,0,0 from UCS to DisplayDCS : "
  16.                  + basePoint.TranslateCoordinates(
  17.                       dbExtensions.CoOrds.UCS,
  18.                       dbExtensions.CoOrds.DisplayDCS ).ToString());
  19.            
  20.             ed.WriteMessage("\n Translate Point 0,0,0 from WCS to UCS : "
  21.                  + basePoint.TranslateCoordinates(
  22.                       dbExtensions.CoOrds.WCS,
  23.                       dbExtensions.CoOrds.UCS ).ToString());
  24.          
  25.             ed.WriteMessage("\n Translate Point 0,0,0 from WCS to DisplayDCS : "
  26.                 + basePoint.TranslateCoordinates(
  27.                      dbExtensions.CoOrds.WCS,
  28.                      dbExtensions.CoOrds.DisplayDCS ).ToString());
  29.  
  30.             ed.WriteMessage("\n Translate Point 0,0,0 from DisplayDCS to WCS : "
  31.                 + basePoint.TranslateCoordinates(
  32.                      dbExtensions.CoOrds.DisplayDCS,
  33.                      dbExtensions.CoOrds.WCS ).ToString());
  34.  
  35.             ed.WriteMessage("\n Translate Point 0,0,0 from DisplayDCS to UCS : "
  36.                 + basePoint.TranslateCoordinates(
  37.                      dbExtensions.CoOrds.DisplayDCS,
  38.                      dbExtensions.CoOrds.UCS).ToString());
  39.  
  40.         }

Tested in a drawing set up like this ..

Current ucs name:  *WORLD*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: o

Specify new origin point <0,0,0>: 100,100,100

Command: UCS
Current ucs name:  *NO NAME*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: z
Specify rotation angle about Z axis <90>: 20

Command: UCS
Current ucs name:  *NO NAME*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: y
Specify rotation angle about Y axis <90>: -20

Command: UCS
Current ucs name:  *NO NAME*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: x
Specify rotation angle about X axis <90>: 20

Command: UCS
Current ucs name:  *NO NAME*
Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World>: s
Enter name to save current UCS or [?]: tempTest

Command: _-view
Enter an option [?/Delete/Orthographic/Restore/Save/sEttings/Window]: _seiso

Intersecting Lines Lines on World at 0,0,0
Circle on tempTest at 0,0,0

(vlax-dump-object
  (vla-item (vla-get-usercoordinatesystems
              (vla-get-activedocument (vlax-get-acad-object))
            )
            "tempTest"
  )
)
; IAcadUCS:
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00d74d3c>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 01465d38>
;   Handle (RO) = "81"
;   HasExtensionDictionary (RO) = 0
;   Name = "tempTest"
;   ObjectID (RO) = 2126872648
;   ObjectName (RO) = "AcDbUCSTableRecord"
;   Origin = (100.0 100.0 100.0)
;   OwnerID (RO) = 2126855224
;   XVector = (0.883022 0.321394 0.34202)
;   YVector = (-0.431317 0.843013 0.321394)




(trans '(0 0 0) acucs acWorld )
;=> (100.0 100.0 100.0)

(trans '(0 0 0) acucs acDisplayDCS )
;=> (141.421 81.6497 57.735)

(trans '(0 0 0) acWorld acUcs)
;=> (-154.644 -73.309 -26.6672)

(trans '(0 0 0) acWorld acDisplayDCS)
;=> (0.0 0.0 0.0)

(trans '(0 0 0) acDisplayDCS acWorld)
;=> (0.0 0.0 0.0)

(trans '(0 0 0) acDisplayDCS acUcs)
;=> (-154.644 -73.309 -26.6672)


Command: NetLoad
Command: TranslatePoint

 Translate Point 0,0,0 from UCS to WCS :           (100, 100, 100)
 Translate Point 0,0,0 from UCS to DisplayDCS : (141.42135623731, 81.6496580927726, 57.7350269189626)
 Translate Point 0,0,0 from WCS to UCS :            (-154.643616972843, -73.3090309814871, -26.6671653182726)
 Translate Point 0,0,0 from WCS to DisplayDCS : (0,0,0)
 Translate Point 0,0,0 from DisplayDCS to WCS : (0,0,0)
 Translate Point 0,0,0 from DisplayDCS to UCS :  (-154.643616972843, -73.3090309814871, -26.6671653182726)


So, it seems to work ok.
the drawing piccy attached
edit:
AC2002 Drawing attached
« Last Edit: April 24, 2014, 05:07:44 PM by Kerry »
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: acedTrans to .NET
« Reply #2 on: March 01, 2008, 04:13:10 AM »
Kerry,

Since you removed the first code post, I have nothing to compare the second against, so what did you find out was wrong with the first...if anything???

Cheers,
Glenn.
Me

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: acedTrans to .NET
« Reply #3 on: March 01, 2008, 08:33:58 AM »

considering that the  thread sat here for a week without comment I didn't think anyone would care :-)
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: acedTrans to .NET
« Reply #4 on: March 01, 2008, 02:28:13 PM »
Yes, I do, but I have been under the weather lately is all...

Cheers,
Glenn.
Me

Bryco

  • Water Moccasin
  • Posts: 1848
Re: acedTrans to .NET
« Reply #5 on: March 01, 2008, 04:32:22 PM »
Hope you get well soon, Glenn.

MP

  • Seagull
  • Posts: 17345
Re: acedTrans to .NET
« Reply #6 on: March 01, 2008, 06:59:21 PM »
Ditto that, sorry to hear you haven't been well. Hope it passes soon Glenn.
\|// Set goal. Experiment tirelessly until
|Oo| practice has become expertise.  Loop.
|- | LinkedIn | Dropbox

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: acedTrans to .NET
« Reply #7 on: March 01, 2008, 07:48:26 PM »
be well Glenn.
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<--

Bryco

  • Water Moccasin
  • Posts: 1848
Re: acedTrans to .NET
« Reply #8 on: March 02, 2008, 12:02:35 PM »
Kerry this is a keeper, I thought the dcs may throw a wobbler on a twisted view but it works fine.

For some reason I can't get the  "this" in  "public static AcGe.Point3d TranslateCoordinates(this AcGe.Point3d" to not error, is there something I need to add to the top?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: acedTrans to .NET
« Reply #9 on: March 02, 2008, 03:09:04 PM »
hi Bryco,

in this case, the this keyword is used in an extension method only .. so the point is not actually a parameter.
did you want to use the method as a conventional method ?


 

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<--

Bryco

  • Water Moccasin
  • Posts: 1848
Re: acedTrans to .NET
« Reply #10 on: March 02, 2008, 04:13:33 PM »
basePoint.TranslateCoordinates looks so useful I just wondered if it could be added as a method to point3d. AcGe.Point3d newp=  dbExtensions.TranslateCoordinates
(basePoint, dbExtensions.CoOrds.UCS, dbExtensions.CoOrds.WCS); works good, but sometimes I wish the enums could work without prefixing them.

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: acedTrans to .NET
« Reply #11 on: March 04, 2008, 04:14:46 AM »
Thanks lads - feeling better now...it's amazing what some good sleep will do for you.

Kerry,

Nicely done - extension methods are looking interesting purely from a concise code base point of view.

Cheers,
Glenn.
Me

gile

  • Water Moccasin
  • Posts: 2221
  • Marseille, France
Re: acedTrans to .NET
« Reply #12 on: July 06, 2009, 05:53:13 PM »
Hi,

Thanks Kerry !
Quite old topic, but very intersting.
I was missing a Trans method in .NET (it's so usefull with LISP).

So, to add to the GeomExt I began here, I complete Kerry's code to implement all parameters possibilities (as trans (LISP) or acedTrans).
The coordinates systems can be specified as a coordinates system (CoordSystem enum member), an entity (ObjectId) or an extrusion direction (Vector3d).
If the disp parameter (int) is specified and other than 0, the point is treated as a vector (displacement).

As it's forbidding coding (18 overloads), I share it, if someones are interseted...

Code - C#: [Select]
  1. [DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
  2.         private static extern int acedTrans(
  3.             double[] point,
  4.             IntPtr fromResbuf,
  5.             IntPtr toResbuf,
  6.             int displacement,
  7.             double[] result
  8.         );
  9.  
  10.        public enum CoordSystem
  11.         {
  12.             WCS = 0,
  13.             UCS,
  14.             DCS,
  15.             PSDCS
  16.         }
  17.  
  18.         // Coordinates System / Coordinates System
  19.         public static Point3d Trans(this Point3d pt, CoordSystem from, CoordSystem to)
  20.         {
  21.             double[] result = new double[] { 0, 0, 0 };
  22.             acedTrans(pt.ToArray(),
  23.                 new ResultBuffer(new TypedValue(5003, from)).UnmanagedObject,
  24.                 new ResultBuffer(new TypedValue(5003, to)).UnmanagedObject,
  25.                 0,
  26.                 result);
  27.             return new Point3d(result);
  28.         }
  29.         // Coordinates System / Coordinates System (displacement)
  30.         public static Point3d Trans(this Point3d pt, CoordSystem from, CoordSystem to, int disp)
  31.         {
  32.             double[] result = new double[] { 0, 0, 0 };
  33.             acedTrans(pt.ToArray(),
  34.                 new ResultBuffer(new TypedValue(5003, from)).UnmanagedObject,
  35.                 new ResultBuffer(new TypedValue(5003, to)).UnmanagedObject,
  36.                 disp,
  37.                 result);
  38.             return new Point3d(result);
  39.         }
  40.         // Entity / Entity
  41.         public static Point3d Trans(this Point3d pt, ObjectId from, ObjectId to)
  42.         {
  43.             double[] result = new double[] { 0, 0, 0 };
  44.             acedTrans(pt.ToArray(),
  45.                 new ResultBuffer(new TypedValue(5006, from)).UnmanagedObject,
  46.                 new ResultBuffer(new TypedValue(5006, to)).UnmanagedObject,
  47.                 0,
  48.                 result);
  49.             return new Point3d(result);
  50.         }
  51.         // Entity / Entity (displacement)
  52.         public static Point3d Trans(this Point3d pt, ObjectId from, ObjectId to, int disp)
  53.         {
  54.             double[] result = new double[] { 0, 0, 0 };
  55.             acedTrans(pt.ToArray(),
  56.                 new ResultBuffer(new TypedValue(5006, from)).UnmanagedObject,
  57.                 new ResultBuffer(new TypedValue(5006, to)).UnmanagedObject,
  58.                 disp,
  59.                 result);
  60.             return new Point3d(result);
  61.         }
  62.         // Vector / Vector
  63.         public static Point3d Trans(this Point3d pt, Vector3d from, Vector3d to)
  64.         {
  65.             double[] result = new double[] { 0, 0, 0 };
  66.             acedTrans(pt.ToArray(),
  67.                 new ResultBuffer(new TypedValue(5009, new Point3d(from.X, from.Y, from.Z))).UnmanagedObject,
  68.                 new ResultBuffer(new TypedValue(5009, new Point3d(to.X, to.Y, to.Z))).UnmanagedObject,
  69.                 0,
  70.                 result);
  71.             return new Point3d(result);
  72.         }
  73.         // Vector / Vector (displacement)
  74.         public static Point3d Trans(this Point3d pt, Vector3d from, Vector3d to, int disp)
  75.         {
  76.             double[] result = new double[] { 0, 0, 0 };
  77.             acedTrans(pt.ToArray(),
  78.                 new ResultBuffer(new TypedValue(5009, new Point3d(from.X, from.Y, from.Z))).UnmanagedObject,
  79.                 new ResultBuffer(new TypedValue(5009, new Point3d(to.X, to.Y, to.Z))).UnmanagedObject,
  80.                 disp,
  81.                 result);
  82.             return new Point3d(result);
  83.         }
  84.         // Entity / Coordinates System
  85.         public static Point3d Trans(this Point3d pt, ObjectId from, CoordSystem to)
  86.         {
  87.             double[] result = new double[] { 0, 0, 0 };
  88.             acedTrans(pt.ToArray(),
  89.                 new ResultBuffer(new TypedValue(5006, from)).UnmanagedObject,
  90.                 new ResultBuffer(new TypedValue(5003, to)).UnmanagedObject,
  91.                 0,
  92.                 result);
  93.             return new Point3d(result);
  94.         }
  95.         // Entity / Coordinates System (displacement)
  96.         public static Point3d Trans(this Point3d pt, ObjectId from, CoordSystem to, int disp)
  97.         {
  98.             double[] result = new double[] { 0, 0, 0 };
  99.             acedTrans(pt.ToArray(),
  100.                 new ResultBuffer(new TypedValue(5006, from)).UnmanagedObject,
  101.                 new ResultBuffer(new TypedValue(5003, to)).UnmanagedObject,
  102.                 disp,
  103.                 result);
  104.             return new Point3d(result);
  105.         }
  106.         // Coordinates System / Entity
  107.         public static Point3d Trans(this Point3d pt, CoordSystem from, ObjectId to)
  108.         {
  109.             double[] result = new double[] { 0, 0, 0 };
  110.             acedTrans(pt.ToArray(),
  111.                 new ResultBuffer(new TypedValue(5003, from)).UnmanagedObject,
  112.                 new ResultBuffer(new TypedValue(5006, to)).UnmanagedObject,
  113.                 0,
  114.                 result);
  115.             return new Point3d(result);
  116.         }
  117.         // Coordinates System / Entity (displacement)
  118.         public static Point3d Trans(this Point3d pt, CoordSystem from, ObjectId to, int disp)
  119.         {
  120.             double[] result = new double[] { 0, 0, 0 };
  121.             acedTrans(pt.ToArray(),
  122.                 new ResultBuffer(new TypedValue(5003, from)).UnmanagedObject,
  123.                 new ResultBuffer(new TypedValue(5006, to)).UnmanagedObject,
  124.                 disp,
  125.                 result);
  126.             return new Point3d(result);
  127.         }
  128.         // Coordinates System / Vector)
  129.         public static Point3d Trans(this Point3d pt, CoordSystem from, Vector3d to)
  130.         {
  131.             double[] result = new double[] { 0, 0, 0 };
  132.             acedTrans(pt.ToArray(),
  133.                 new ResultBuffer(new TypedValue(5003, from)).UnmanagedObject,
  134.                 new ResultBuffer(new TypedValue(5009, new Point3d(to.X, to.Y, to.Z))).UnmanagedObject,
  135.                 0,
  136.                 result);
  137.             return new Point3d(result);
  138.         }
  139.         // Coordinates System / Vector (displacement)
  140.         public static Point3d Trans(this Point3d pt, CoordSystem from, Vector3d to, int disp)
  141.         {
  142.             double[] result = new double[] { 0, 0, 0 };
  143.             acedTrans(pt.ToArray(),
  144.                 new ResultBuffer(new TypedValue(5003, from)).UnmanagedObject,
  145.                 new ResultBuffer(new TypedValue(5009, new Point3d(to.X, to.Y, to.Z))).UnmanagedObject,
  146.                 disp,
  147.                 result);
  148.             return new Point3d(result);
  149.         }
  150.         // Vector / Coordinates System
  151.         public static Point3d Trans(this Point3d pt, Vector3d from, CoordSystem to)
  152.         {
  153.             double[] result = new double[] { 0, 0, 0 };
  154.             acedTrans(pt.ToArray(),
  155.                 new ResultBuffer(new TypedValue(5009, new Point3d(from.X, from.Y, from.Z))).UnmanagedObject,
  156.                 new ResultBuffer(new TypedValue(5003, to)).UnmanagedObject,
  157.                 0,
  158.                 result);
  159.             return new Point3d(result);
  160.         }
  161.         // Vector / Coordinates System (displacement)
  162.         public static Point3d Trans(this Point3d pt, Vector3d from, CoordSystem to, int disp)
  163.         {
  164.             double[] result = new double[] { 0, 0, 0 };
  165.             acedTrans(pt.ToArray(),
  166.                 new ResultBuffer(new TypedValue(5009, new Point3d(from.X, from.Y, from.Z))).UnmanagedObject,
  167.                 new ResultBuffer(new TypedValue(5003, to)).UnmanagedObject,
  168.                 disp,
  169.                 result);
  170.             return new Point3d(result);
  171.         }
  172.         // Entity / Vector
  173.         public static Point3d Trans(this Point3d pt, ObjectId from, Vector3d to)
  174.         {
  175.             double[] result = new double[] { 0, 0, 0 };
  176.             acedTrans(pt.ToArray(),
  177.                 new ResultBuffer(new TypedValue(5006, from)).UnmanagedObject,
  178.                 new ResultBuffer(new TypedValue(5009, new Point3d(to.X, to.Y, to.Z))).UnmanagedObject,
  179.                 0,
  180.                 result);
  181.             return new Point3d(result);
  182.         }
  183.         // Entity / Vector (displacement)
  184.         public static Point3d Trans(this Point3d pt, ObjectId from, Vector3d to, int disp)
  185.         {
  186.             double[] result = new double[] { 0, 0, 0 };
  187.             acedTrans(pt.ToArray(),
  188.                 new ResultBuffer(new TypedValue(5006, from)).UnmanagedObject,
  189.                 new ResultBuffer(new TypedValue(5009, new Point3d(to.X, to.Y, to.Z))).UnmanagedObject,
  190.                 disp,
  191.                 result);
  192.             return new Point3d(result);
  193.         }
  194.         // Vector / Entity
  195.         public static Point3d Trans(this Point3d pt, Vector3d from, ObjectId to)
  196.         {
  197.             double[] result = new double[] { 0, 0, 0 };
  198.             acedTrans(pt.ToArray(),
  199.                 new ResultBuffer(new TypedValue(5009, new Point3d(from.X, from.Y, from.Z))).UnmanagedObject,
  200.                 new ResultBuffer(new TypedValue(5006, to)).UnmanagedObject,
  201.                 0,
  202.                 result);
  203.             return new Point3d(result);
  204.         }
  205.         // Vector / Entity (displacement)
  206.         public static Point3d Trans(this Point3d pt, Vector3d from, ObjectId to, int disp)
  207.         {
  208.             double[] result = new double[] { 0, 0, 0 };
  209.             acedTrans(pt.ToArray(),
  210.                 new ResultBuffer(new TypedValue(5009, new Point3d(from.X, from.Y, from.Z))).UnmanagedObject,
  211.                 new ResultBuffer(new TypedValue(5006, to)).UnmanagedObject,
  212.                 disp,
  213.                 result);
  214.             return new Point3d(result);
  215.         }
« Last Edit: April 24, 2014, 05:08:14 PM by Kerry »
Speaking English as a French Frog

kdub

  • Mesozoic relic
  • SuperMod
  • Swamp Rat
  • Posts: 1349
  • class keyThumper<T>:ILazy<T>
Re: acedTrans to .NET
« Reply #13 on: July 06, 2009, 07:45:58 PM »

You're welcome gile :)

There are a few older topics on the forum that are worth reading.

Unfortunately I haven't done any serious code writing for a while ... hope that will change soon  :|

Regards
Kerry
called Kerry in my other life

Sometimes the question is more important than the answer.
#ridesober

Jeff H

  • Needs a day job
  • Posts: 6034
Re: acedTrans to .NET
« Reply #14 on: April 28, 2014, 01:53:59 AM »
Just a post to bump this thread. Got link from here
Can't believe I never seen this thread.
Very useful and hopefully bump gets google bots more active on this.


Thanks Kerry and gile definite keeper.