RE: Q about C# and PolygonMesh.Set

Date : Sun, 4 Feb 2007 14:11:07 -0500
To : <XSI(at)Softimage.COM>
From : Marc-André Belzile <mbelzile(at)Softimage.COM>
Subject : RE: Q about C# and PolygonMesh.Set
You're right. Data passed from C# to XSI are marshalled by a COM module supplied by .NET, therefore arrays must be filled with safearray compliant types (i.e. object). 

-mab

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of squid
Sent: February 4, 2007 1:14 PM
To: XSI(at)Softimage.COM
Subject: Re: Q about C# and PolygonMesh.Set

it's the way you are constructing your arrays.

try this :

   public bool Execute( Context in_ctxt )
   {
       try
       {
           Object in_vertices = new Object[12]{
               0,0,0,
               0,0,1,
               1,0,1,
               1,0,0
               };

           Object in_polygonData = new Object[5] { 4, 0, 1, 2, 3 
};                   X3DObject oRoot = GetXSI().ActiveSceneRoot as 
X3DObject;
           X3DObject o = oRoot.AddPolygonMesh(in_vertices, in_polygonData, "aCube");

       }
       catch (Exception e)
       {
           Info("Make Flake Died! : " + e);
       }
       return true;
   }

hope that helped.

Jon
squid(at)3d-palace.com


Anthony Rossano wrote:
> Hi Marc-André;
> Thanks - let me know when it gets fixed and I'll test it for you.
> On the scripting demo, if you mean the ability to run simple C# in the 
> script editor, Yes! I found that right away and it's a big help!
> Thanks -
> ATR
>
>
> On Sun, 4 Feb 2007 11:48:39 -0500, Marc-André Belzile wrote:
>   
>> Hi Anthony,
>>
>> Looks like a safearray handling issue on our end. I'll give it a try. 
>>
>> FYI, you can use the C# scripting demo which is really convenient for 
>> learning/testing C# with XSI.
>>
>> -mab
>>
>> -----Original Message-----
>> From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On 
>> Behalf Of Anthony Rossano
>> Sent: February 3, 2007 7:10 PM
>> To: XSI(at)Softimage.COM
>> Subject: Q about C# and PolygonMesh.Set
>>
>> Hi All -
>> I am learning up on the C# SDK in v6.0, which is convenient, mostly. 
>> Using the Plug-In view and the SDK_Wizard is awesome. 
>>
>> I have been unable, however, to actually MAKE any geometry with it. I 
>> can futz with existing points, but using the 
>> ActiveSceneRoot.AddPolygonMesh method crashes XSI, or in other cases 
>> errors out (though it's in a try/catch loop) as does the 
>> PolygonMesh.Set method.
>>
>> I see a bunch of confusing info about what Softimage calls 'output 
>> arguments' (as far as I can tell, what I would call 'passing by 
>> reference', or 'pointers') but I cannot determine from that what 
>> should be wrong with passing arrays of vert indices and polygon data 
>> to these functions.
>>
>> Has anyone done this with C#? Where did I go wrong? Or is it just not 
>> working in C# and I should use C++ for this sort of thing?
>> Thanks in advance!!
>> ATR
>>
>> #### here's the code....it's running as a command. ####
>>
>>
>>         try
>>         {
>>             //needs in_vertices, in_polygonData, name. 
>>             String in_bstrName = "myObj";
>>             Object in_vertices = new object();
>>             Object in_polygonData = new object();
>>
>>             //fill the verts (a one dimension array of triplet values
>>             Double[] verts = { 
>>                 0,0,0,
>>                 0,0,1,
>>                 1,0,1,
>>                 1,0,0
>>             };
>>             in_vertices = verts;
>>
>>             //fill the polydata
>>             long[] pd = { 4, 0, 1, 2, 3 }; //counterclockwise, and 
>> the list is zero based.
>>             in_polygonData = pd;
>>
>>
>>
>>             // creat the object
>>             XSIApplication xsi = GetXSI();
>>             Model root = xsi.ActiveSceneRoot; //actually an object of 
>> type Model
>>             X3DObject o = root.AddPolygonMesh(verts, pd, in_bstrName);
>>             //the above fails with a cryptic message. "External 
>> component has thrown an exception."
>>
>>
>>             X3DObject o2 = root.AddGeometry("cube", "meshSurface", 
>> "shizzy");
>>             PolygonMesh p =
>> (PolygonMesh)o2.ActivePrimitive.GetGeometry2(1,
>> siConstructionMode.siConstructionModeModeling);
>>             
>>             p.Set(verts, pd); //also dies:
>>             //    System.Runtime.InteropServices.SEHException: External 
>> component has thrown an exception.
>>             //    at Softimage.XSIOM.PolygonMesh.Set(Object 
>> in_vertices, Object in_polygonData)
>>             //    at make_flake.Execute(Context in_ctxt)
>>
>>
>>         }//end try
>>         catch (Exception e) {Info ("make flake died: " + e); };
>>
>>
>>
>> **    Anthony Rossano    **
>> *   CEO and TD, Mesmer    *
>> *  http://www.mesmer.com  *
>> *   anthor(at)mesmer.com     *
>> *       206.369.5205      *
>> ***************************
>> ---
>> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
>> unsubscribe xsi
>>
>> ---
>> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
>> unsubscribe xsi
>>     
> **    Anthony Rossano    **
> *   CEO and TD, Mesmer    *
> *  http://www.mesmer.com  *
> *   anthor(at)mesmer.com     *
> *       206.369.5205      *
> ***************************
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi
>
>
>   

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.