• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Mentor
    Posts: 247
    Registered: ‎12-04-2009
    Accepted Solution

    Can you convert .NEt to VisualC++ARX?

    151 Views, 2 Replies
    01-13-2013 08:16 PM

    Hello2013

    I need convert the source . NET to C++ARX?
    Please  help, can you translate source1 to source2?
    You replace "????" with your source.
    The string "????" is idem with "???".
    Many thanks............


    [source1=csharp]
        // ByA: The source (c#) by KeanWalmsley.
        void GetNormalAndPoint(
         AcGe.Surface surf, ref Vector3d normal, ref Point3d pt)
        {
          Interval[] box = surf.GetEnvelope();
          double p1 = box[0].LowerBound + box[0].Length / 2.0;
          double p2 = box[1].LowerBound + box[1].Length / 2.0;
          Point2d ptParams = new Point2d(p1, p2);
          ???
          PointOnSurface pos = new PointOnSurface(surf, ptParams);
          normal = pos.GetNormal(ptParams);
          pt = pos.GetPoint(ptParams);
        }
    [/source1=csharp]

    [source2=c++arx]
        int GetNormalAndPoint(AcGeSurface surf, &AcGeVector3d normal, AcGePoint3d &pt)
                   {                                                                                    
                      int rr=RTREJ;
                   AcGeInterval uParam;
                   AcGeInterval vParam;
                   int p1ok=0;
                   double p1;
                   double p2;
                   ((AcGeExternalBoundedSurface*)surf)->getEnvelope(uParam, vParam);    
                   if ((uParam.isBounded()) && (vParam.isBounded()))
                      {  p1ok=1;
                         p1 = uParam.lowerBound() + (uParam.length() / 2.0);
                         p2 = vParam.lowerBound() + (vParam.length() / 2.0);
                      };
                   if (p1ok==0) { ads_printf(_T("\n procedures GetNormalAndPoint failed"));return(rr);};
                   AcGePoint2d ptParams(p1,p2);                                               
                   AcGePoint3d pos = ((AcGeExternalBoundedSurface*)surf)->evalPoint(ptParams);
                   ????
                   return(rr);
                };
    [/source2=c++arx]
    :smileyvery-happy:


    Please use plain text.
    Valued Mentor
    Posts: 321
    Registered: ‎05-06-2012

    Re: Can you convert .NEt to VisualC++ARX?

    01-14-2013 05:37 AM in reply to: diagodose2009

    If you mean automate conversion from C# to C++, no that's not going to be possible.

     

    The basic ways that the APIs and the languages work are different, and becauss the managed wrappers often do more than just delegate to a native C++ API (mostly relating to marshaling data from native to managed and visa verse), it's not as simple as converting a call to a managed api into a call to a native API. There are also many managed types that have no direct native counterparts, or are radically different from their native counterparts.

     

    If your intention is automating conversion as a way of getting around having to learn C++ and/or the native ObjectARX API, then please don't waste anyone's time with that.

    Please use plain text.
    Mentor
    Posts: 247
    Registered: ‎12-04-2009

    Re: Can you convert .NEt to VisualC++ARX?

    01-15-2013 06:19 PM in reply to: DiningPhilosopher

    Thank you, for all

    You replace "????"with three lines:

    :smileysurprised:

    [source=c++arx]

         AcGePoint3d pos = ((AcGeExternalBoundedSurface*)         
                                     surfaceGeometry)->evalPoint(ptParams);
           AcGePointOnSurface normalobj(*surfaceGeometry,ptParams);
          AcGeVector3d normal=normalobj.normal(ptParams);
         AcGePoint3dptdoi=normalobj.point(ptParams);  //euaici: ptdoi is idem with  pt
    [/source=c++arx]

    Please use plain text.