Exemple #1
0
		public override void writeASCII(MOStream outstream)
		{
			MOStream instream = new MOStream(MOStream.getCPtr(outstream).Handle, false);
			MStreamUtils.writeDouble(outstream, fValue);
			MStreamUtils.writeChar(outstream, ' ');
			return;
		}
Exemple #2
0
        public override void writeBinary(MOStream outstream)
        {
            MOStream instream = new MOStream(MOStream.getCPtr(outstream).Handle, false);

            MStreamUtils.writeDouble(outstream, fValue, true);
            return;
        }
Exemple #3
0
        public override int write(Structure dataToWrite, MOStream cDst)
        {
            MStreamUtils.writeCharBuffer(cDst, "<?xml version='1.0' encoding='UTF-8'?>\n");

            // Start with the main structure tag containing the name
            string rootString = "<" + structureTag + " " + structureNameAttribute + "='" + dataToWrite.name + "'>\n";

            MStreamUtils.writeCharBuffer(cDst, rootString);

            // Write out each structure member in its own tag
            for (StructureIterator iterator = dataToWrite.begin(); iterator != dataToWrite.end(); iterator = iterator.next())
            {
                string memberString = "    <" + memberTag + " " + memberNameAttribute + "='" + iterator.memberName() + "'"
                                      + " " + memberTypeAttribute + "='" + Member.typeName(iterator.memberType()) + "'";

                if (iterator.memberLength() != 1)
                {
                    memberString = memberString + " " + memberDimAttribute + "='" + iterator.memberLength() + "'";
                }

                memberString += "/>\n";

                MStreamUtils.writeCharBuffer(cDst, memberString);
            }

            rootString = "</" + structureTag + ">";
            MStreamUtils.writeCharBuffer(cDst, rootString);
            return(0);
        }
Exemple #4
0
        public override void writeASCII(MOStream outstream)
        {
            MOStream instream = new MOStream(MOStream.getCPtr(outstream).Handle, false);

            MStreamUtils.writeDouble(outstream, fValue);
            MStreamUtils.writeChar(outstream, ' ');
            return;
        }
Exemple #5
0
 public override void writeBinary(MOStream stream)
 //
 // Description
 //    NOT IMPLEMENTED
 //
 {
     MGlobal.displayInfo("apiMeshData.writeBinary is called.");
     return;
 }
Exemple #6
0
		public override void writeBinary(MOStream stream)
		//
		// Description
		//    NOT IMPLEMENTED
		//
		{
            MGlobal.displayInfo("apiMeshData.writeBinary is called.");
			return;
		}
        public override void getFormatDescription(MOStream info)
        {
            string msgPre = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLInfoPre);
            string msgPost = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLInfoPost);

            MStreamUtils.writeChar(info,msgPre[0]);

            for (uint i = (uint)Member.eDataType.kFirstType; i < (uint)Member.eDataType.kLastType; ++i)
            {
                if (i != (uint)Member.eDataType.kFirstType)
                {
                    MStreamUtils.writeCharBuffer(info,", ");
                }
            }

            MStreamUtils.writeChar(info,msgPost[0]);
        }
Exemple #8
0
        public override void getFormatDescription(MOStream info)
        {
            string msgPre  = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLInfoPre);
            string msgPost = MStringResource.getString(MetaDataRegisterMStringResources.kStructureXMLInfoPost);

            MStreamUtils.writeChar(info, msgPre[0]);

            for (uint i = (uint)Member.eDataType.kFirstType; i < (uint)Member.eDataType.kLastType; ++i)
            {
                if (i != (uint)Member.eDataType.kFirstType)
                {
                    MStreamUtils.writeCharBuffer(info, ", ");
                }
            }

            MStreamUtils.writeChar(info, msgPost[0]);
        }
        public override void doCreate()
        {
            if (fMeshes.length != 1)
            {
                throw new System.ApplicationException("ExportMetadataCmd: do not support less or more then 1 mesh.");
            }
            MFnMesh mesh = new MFnMesh(fMeshes[0]);

            displayInfo(mesh.fullPathName);

            Associations associationsToWrite = mesh.metadata;

            if (associationsToWrite == null)
            {
                throw new System.ApplicationException("ExportMetadataCmd: no association to write.");
            }

            String errors = "";

            // Dump either to a file or the return string, depending on which was
            // requested.
            //
            MOStream destination = MStreamUtils.CreateOFStream(fileName);

            if (fSerialize.write(associationsToWrite, destination, ref errors) == 0)
            {
                setResult(fileName);
            }
            else
            {
                String msg = MStringResource.getString(MetaDataRegisterMStringResources.kExportMetadataFailedFileWrite);
                displayError(msg);
            }
            MStreamUtils.Close(destination);
            destination = null;

            if (errors != null && errors.Length > 0)
            {
                displayError(errors);
                return;
            }

            return;
        }
		public override int write(Structure dataToWrite, MOStream cDst)
		{
			MStreamUtils.writeCharBuffer(cDst, "<?xml version='1.0' encoding='UTF-8'?>\n");

			// Start with the main structure tag containing the name
			string rootString = "<" + structureTag + " " + structureNameAttribute + "='" + dataToWrite.name + "'>\n";
			MStreamUtils.writeCharBuffer(cDst,rootString);

			// Write out each structure member in its own tag
            for (StructureIterator iterator = dataToWrite.begin(); iterator != dataToWrite.end(); iterator = iterator.next())
			{
				string memberString = "    <" + memberTag + " " + memberNameAttribute + "='" + iterator.memberName() + "'"
										+ " " + memberTypeAttribute + "='" + Member.typeName(iterator.memberType()) + "'";

                if (iterator.memberLength() != 1)
				{
					memberString = memberString + " " + memberDimAttribute + "='" + iterator.memberLength() + "'";
				}

				memberString += "/>\n";

				MStreamUtils.writeCharBuffer(cDst,memberString);
			}

			rootString = "</" + structureTag + ">";
			MStreamUtils.writeCharBuffer(cDst,rootString);
			return 0;
		}
Exemple #11
0
		public override void writeBinary(MOStream outstream)
		{
			MOStream instream = new MOStream(MOStream.getCPtr(outstream).Handle, false);
			MStreamUtils.writeDouble(outstream, fValue, true);
			return;
		}
Exemple #12
0
        public override void redoIt()
        {
            MObject  dependNode   = new MObject();
            MOStream stdoutstream = MStreamUtils.stdOutStream();

            for (; !iter.isDone; iter.next())
            {
                // Get the selected dependency node and create
                // a function set for it
                //
                try
                {
                    iter.getDependNode(dependNode);
                }
                catch (System.Exception)
                {
                    MStreamUtils.writeCharBuffer(MStreamUtils.stdErrorStream(), "Error getting the dependency node");
                    continue;
                }

                MFnDependencyNode fnDN;
                try
                {
                    fnDN = new MFnDependencyNode(dependNode);
                }
                catch (System.Exception)
                {
                    MStreamUtils.writeCharBuffer(MStreamUtils.stdErrorStream(), "Error creating MFnDependencyNode");
                    continue;
                }

                MFnTypedAttribute fnAttr  = new MFnTypedAttribute();
                MObject           newAttr = fnAttr.create("blindDoubleData", "BDD", blindDoubleData.tid);

                try
                {
                    fnDN.addAttribute(newAttr, MFnDependencyNode.MAttrClass.kLocalDynamicAttr);
                }
                catch (System.Exception)
                {
                    // do nothing
                    // addAttribute only need call once, the redundant calls will return false (throw exception)
                }

                // Create a plug to set and retrieve value off the node.
                //
                MPlug plug = new MPlug(dependNode, newAttr);


                // ----------------------------------- Attention ------------------------------------
                // --------------------------------- Downcast Begin -----------------------------------
                // the following codes are used to get the c# object
                //
                MFnPluginData pdFnCreator = new MFnPluginData();

                // 1. you cannot gain blindDoubleData by the following code
                //    {code}
                //          blindDoubleData newData = new blindDoubleData()
                //    {code}
                //    As we need to keep the relationship between c# impl and c++ instance pointer
                //    We cannot use the above ctor codes, otherwise, the mandatory information used for down casting is omitted

                // 2. you cannot use the tempData gained by the following code
                //    {code}
                //          MObject tempData = pdFnCreator.create(blindDoubleData.tid);
                //    {code}
                //    reason:
                //          tempData is useless, we cannot use tempData to do downcast
                //          the create function gains the tempData by the following code
                //
                //          {code}
                //              newHandle = new MObject(mayaHandle);
                //          {code}
                //
                //     the mayaHandle is the actual pointer, which we store. But we have no information about the newHandle

                // the return object is useless. the data we needed is stored in pdFnCreator
                pdFnCreator.create(blindDoubleData.tid);

                // 3. get "the data" we needed
                blindDoubleData newData = pdFnCreator.data() as blindDoubleData;
                // ---------------------------------- Downcast End -----------------------------------
                if (newData == null)
                {
                    continue;
                }

                newData.value = 3.2;

                plug.setValue(newData);

                // Now try to retrieve the value of the plug as an MObject.
                //
                MObject sData = new MObject();

                try
                {
                    plug.getValue(sData);
                }
                catch (System.Exception)
                {
                    continue;
                }

                // Convert the data back to MPxData.
                //
                MFnPluginData pdFn = new MFnPluginData(sData);

                blindDoubleData data = pdFn.data() as blindDoubleData;

                // Get the value.
                //
                if (null == data)
                {
                    // error
                    MStreamUtils.writeCharBuffer(MStreamUtils.stdErrorStream(), "error: failed to retrieve data.");
                }
                MStreamUtils.writeLine(stdoutstream);
                MStreamUtils.writeCharBuffer(stdoutstream, ">>>>>>>>>>>>>>>>>>>>>>>> blindDoubleData binary >>>>>>>>>>>>>>>>>>>>");
                MStreamUtils.writeLine(stdoutstream);
                data.writeBinary(stdoutstream);
                MStreamUtils.writeLine(stdoutstream);
                MStreamUtils.writeCharBuffer(stdoutstream, ">>>>>>>>>>>>>>>>>>>>>>>> blindDoubleData ascii >>>>>>>>>>>>>>>>>>>>");
                MStreamUtils.writeLine(stdoutstream);
                data.writeASCII(stdoutstream);
            }
            return;
        }
Exemple #13
0
 //
 // Description
 //    NOT IMPLEMENTED
 //
 public override void writeBinary(MOStream stream)
 {
     MGlobal.displayInfo("apiMeshData.writeBinary is called.");
     return;
 }