static NurbsSurface FromHermiteSurface ( DB.DoubleArray paramsU, DB.DoubleArray paramsV, IList <DB.XYZ> points, IList <DB.XYZ> mixedDerivs, IList <DB.XYZ> tangentsU, IList <DB.XYZ> tangentsV ) { var uCount = paramsU.Size; var vCount = paramsV.Size; var hermiteSurface = new HermiteSurface(uCount, vCount); { for (int u = 0; u < uCount; ++u) { hermiteSurface.SetUParameterAt(u, paramsU.get_Item(u)); } for (int v = 0; v < vCount; ++v) { hermiteSurface.SetVParameterAt(v, paramsV.get_Item(v)); } for (int v = 0; v < vCount; ++v) { for (int u = 0; u < uCount; ++u) { hermiteSurface.SetPointAt(u, v, AsPoint3d(points[v * uCount + u])); hermiteSurface.SetTwistAt(u, v, AsVector3d(mixedDerivs[v * uCount + u])); hermiteSurface.SetUTangentAt(u, v, AsVector3d(tangentsU[v * uCount + u])); hermiteSurface.SetVTangentAt(u, v, AsVector3d(tangentsV[v * uCount + u])); } } } return(hermiteSurface.ToNurbsSurface()); }
// 定义获取材质路径的方法 public void ReadAssetProperty(AssetProperty prop, StreamWriter objWriter, List <string> oldPath) { switch (prop.Type) { // Retrieve the value from simple type property is easy. // for example, retrieve bool property value. case AssetPropertyType.Integer: var AssetPropertyInt = prop as AssetPropertyInteger; objWriter.WriteLine(AssetPropertyInt.Name + "= " + AssetPropertyInt.Value.ToString() + ";" + AssetPropertyInt.IsReadOnly.ToString()); break; case AssetPropertyType.Distance: var AssetPropertyDistance = prop as AssetPropertyDistance; objWriter.WriteLine(AssetPropertyDistance.Name + "= " + AssetPropertyDistance.Value + ";" + AssetPropertyDistance.IsReadOnly.ToString()); break; case AssetPropertyType.Double1: var AssetPropertyDouble = prop as AssetPropertyDouble; objWriter.WriteLine(AssetPropertyDouble.Name + "= " + AssetPropertyDouble.Value.ToString() + ";" + AssetPropertyDouble.IsReadOnly.ToString()); break; case AssetPropertyType.Double2: var AssetPropertyDoubleArray2d = prop as AssetPropertyDoubleArray2d; objWriter.WriteLine(AssetPropertyDoubleArray2d.Name + "= " + AssetPropertyDoubleArray2d.Value.ToString() + ";" + AssetPropertyDoubleArray2d.IsReadOnly.ToString()); break; case AssetPropertyType.Double4: var AssetPropertyDoubleArray4d = prop as AssetPropertyDoubleArray4d; objWriter.WriteLine(AssetPropertyDoubleArray4d.Name + "= " + AssetPropertyDoubleArray4d.Value.ToString() + ";" + AssetPropertyDoubleArray4d.IsReadOnly.ToString()); break; case AssetPropertyType.String: AssetPropertyString val = prop as AssetPropertyString; objWriter.WriteLine(val.Name + "= " + val.Value + ";" + "str" + val.IsReadOnly.ToString()); if (val.Name == "unifiedbitmap_Bitmap") { oldPath.Add(val.Value); } break; case AssetPropertyType.Boolean: AssetPropertyBoolean boolProp = prop as AssetPropertyBoolean; objWriter.WriteLine(boolProp.Name + "= " + boolProp.Value.ToString() + ";" + boolProp.IsReadOnly.ToString()); break; // When you retrieve the value from the data array property, // you may need to get which value the property stands for. // for example, the APT_Double44 may be a transform data. case AssetPropertyType.Double44: AssetPropertyDoubleArray4d transformProp = prop as AssetPropertyDoubleArray4d; Autodesk.Revit.DB.DoubleArray tranformValue = transformProp.Value; objWriter.WriteLine(transformProp.Name + "= " + transformProp.Value.ToString() + ";" + tranformValue.IsReadOnly.ToString()); break; // The APT_List contains a list of sub asset properties with same type. case AssetPropertyType.List: AssetPropertyList propList = prop as AssetPropertyList; IList <AssetProperty> subProps = propList.GetValue(); if (subProps.Count == 0) { break; } switch (subProps[0].Type) { case AssetPropertyType.Integer: foreach (AssetProperty subProp in subProps) { AssetPropertyInteger intProp = subProp as AssetPropertyInteger; int intValue = intProp.Value; objWriter.WriteLine(intProp.Name + "= " + intProp.Value.ToString() + ";" + intProp.IsReadOnly.ToString()); } break; case AssetPropertyType.String: foreach (AssetProperty subProp in subProps) { AssetPropertyString intProp = subProp as AssetPropertyString; string intValue = intProp.Value; objWriter.WriteLine(intProp.Name + "= " + intProp.Value.ToString() + ";" + intProp.IsReadOnly.ToString()); } break; } break; case AssetPropertyType.Asset: Asset propAsset = prop as Asset; for (int i = 0; i < propAsset.Size; i++) { ReadAssetProperty(propAsset[i], objWriter, oldPath); } break; case AssetPropertyType.Reference: break; default: objWriter.WriteLine("居然有啥都不是类型的" + prop.Type.ToString()); break; } // Get the connected properties. // please notice that the information of many texture stores here. if (prop.NumberOfConnectedProperties == 0) { return; } foreach (AssetProperty connectedProp in prop.GetAllConnectedProperties()) { ReadAssetProperty(connectedProp, objWriter, oldPath); } }