- 积分
- 24557
- 明经币
- 个
- 注册时间
- 2004-3-17
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2009-5-14 23:31:00
|
显示全部楼层
本帖最后由 作者 于 2009-5-15 7:49:14 编辑
来自于Autodesk开发者网络课程上的例子,会变色的温度计
当你移动当中三个空心的圆圈时,对应的温度数值会自动变化。
用netload命令加载下面的文件体验一下
命令TestOn,然后选择直线
- using System;
- using Autodesk.AutoCAD.ApplicationServices;
- using Autodesk.AutoCAD.DatabaseServices;
- using Autodesk.AutoCAD.EditorInput;
- using Autodesk.AutoCAD.Geometry;
- using Autodesk.AutoCAD.GraphicsInterface;
- using Autodesk.AutoCAD.Runtime;
- [assembly: CommandClass(typeof(abc.TestOverrule))]
- [assembly: ExtensionApplication(typeof(abc.TestOverrule))]
- namespace abc
- {
- #region "HelperClass"
- // Global helper class (singleton). Contains central definitions of some global constants,
- // and a few helper functions
- public class HelperClass
- {
- const String mExtDictName = "SGP_MyDict";
- // Defines Dictionary name for the Extension Dictionary demo
- const String mXRecName = "SGP_MyDATA";
- // Defines Dictionary name for the Extension Dictionary demo
- private static HelperClass mMe;
- // Name of our dictionary in extension dictionary
- public String DictionaryName
- {
- get
- {
- return mExtDictName;
- }
- }
- // Name of our XRecord
- public String XRecordName
- {
- get
- {
- return mXRecName;
- }
- }
- // Protected constructor - to enforce singleton behavior
- protected HelperClass()
- {
- }
- // static function to retrieve one and only instance of singleton
- public static HelperClass GetSingleton
- {
- get
- {
- if (mMe == null)
- {
- mMe = new HelperClass();
- }
- return mMe;
- }
- }
- // Retrieve data (as resbuf) from or Xrecord.
- // Returns null object if there's a problem
- public ResultBuffer GetXRecordData(DBObject obj)
- {
- Xrecord xRec = null;
- ObjectId id = obj.ExtensionDictionary;
- // Make sure we have an ext dict befoore proceeding
- if (id.IsValid)
- {
- // Retrieve data using a transaction
- Database db = Application.DocumentManager.MdiActiveDocument.Database;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- DBDictionary extDict = (DBDictionary)tr.GetObject(id, OpenMode.ForRead, false);
- if (extDict.Contains(DictionaryName))
- {
- // We're assuming that if my dictionary exists, then so will the XRecord in it.
- ObjectId dictId = extDict.GetAt((String)DictionaryName);
- DBDictionary myDict = (DBDictionary)tr.GetObject(dictId, OpenMode.ForRead);
- xRec = (Xrecord)tr.GetObject(myDict.GetAt((String)XRecordName),
- OpenMode.ForRead);
- }
- }
- }
- if (xRec == null)
- {
- return null;
- }
- else
- {
- return xRec.Data;
- }
- }
- // Modifies data in our XRecord.
- // (creates ou rdictionary and XRecoird if it doesn't already exist)
- public void SetXRecordData(DBObject obj, ResultBuffer myData)
- {
- Database db = Application.DocumentManager.MdiActiveDocument.Database;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- DBDictionary myDict = default(DBDictionary);
- Xrecord xRec = null;
- ObjectId id = obj.ExtensionDictionary;
- if (id == ObjectId.Null)
- {
- obj.CreateExtensionDictionary();
- id = obj.ExtensionDictionary;
- }
- DBDictionary extDict = (DBDictionary)tr.GetObject(id, OpenMode.ForWrite);
- if (extDict.Contains(DictionaryName))
- {
- ObjectId dictId = extDict.GetAt((String)DictionaryName);
- myDict = (DBDictionary)tr.GetObject(dictId, OpenMode.ForWrite);
- }
- else
- {
- myDict = new DBDictionary();
- extDict.SetAt((String)DictionaryName, myDict);
- tr.AddNewlyCreatedDBObject(myDict, true);
- }
- if (myDict.Contains(XRecordName))
- {
- xRec = (Xrecord)tr.GetObject(myDict.GetAt((String)XRecordName),
- OpenMode.ForWrite);
- }
- else
- {
- xRec = new Xrecord();
- myDict.SetAt((String)XRecordName, xRec);
- tr.AddNewlyCreatedDBObject(xRec, true);
- }
- xRec.Data = myData;
- tr.Commit();
- }
- }
- }
- #endregion
- // Grip overrule to add our custom grips to the line
- public class MyGripOverrule : GripOverrule
- {
- public class MyGrip : GripData
- {
- private int mGripNum;
- public int Ordinal
- {
- get
- {
- return mGripNum;
- }
- set
- {
- mGripNum = value;
- }
- }
- // Call this to tell the grip to move itself
- public void Move(Vector3d vec)
- {
- GripPoint = GripPoint + vec;
- }
- public override bool ViewportDraw(ViewportDraw worldDraw, ObjectId entityId,
- GripData.DrawType type, Point3d? imageGripPoint, int gripSizeInPixels)
- {
- Point2d unit = worldDraw.Viewport.GetNumPixelsInUnitSquare(GripPoint);
- worldDraw.Geometry.Circle(GripPoint, 1.5 * gripSizeInPixels / unit.X,
- worldDraw.Viewport.ViewDirection);
- return true;
- }
- }
- // Array to hold our 3 grips
- GripData[] mGripData = new GripData[3];
- public override void GetGripPoints(Entity entity, GripDataCollection grips,
- double curViewUnitSize, int gripSize, Vector3d curViewDir, GetGripPointsFlags bitFlags)
- {
- ResultBuffer rb = HelperClass.GetSingleton.GetXRecordData(entity);
- // We assume entity is a line
- Line myLine = (Line)entity;
- // Set grip positions to represent temperatures (we're using Celsius)
- // min temperature
- int temp = (int)rb.AsArray()[1].Value;
- double pos = myLine.StartParam + (temp / 100.0) * (myLine.EndParam - myLine.StartParam);
- Point3d pt = myLine.GetPointAtParameter(pos);
- MyGrip grip = new MyGrip();
- grip.Ordinal = 0;
- grip.GripPoint = pt;
- mGripData[0] = grip;
- // max temperature
- temp = (int)rb.AsArray()[2].Value;
- pos = myLine.StartParam + (temp / 100.0) * (myLine.EndParam - myLine.StartParam);
- pt = myLine.GetPointAtParameter(pos);
- grip = new MyGrip();
- grip.Ordinal = 1;
- grip.GripPoint = pt;
- mGripData[1] = grip;
- // current temperature
- temp = (int)rb.AsArray()[3].Value;
- pos = myLine.StartParam + (temp / 100.0) * (myLine.EndParam - myLine.StartParam);
- pt = myLine.GetPointAtParameter(pos);
- grip = new MyGrip();
- grip.Ordinal = 2;
- grip.GripPoint = pt;
- mGripData[2] = grip;
- // Add our grips to the list
- foreach (MyGrip g in mGripData)
- {
- grips.Add(g);
- }
- // Get the standard line grip points as well
- base.GetGripPoints(entity, grips, curViewUnitSize, gripSize, curViewDir, bitFlags);
- Point3d qq1 = grips[0].GripPoint;
- Point3d qq2 = grips[1].GripPoint;
- }
- public override void MoveGripPointsAt(Entity entity, GripDataCollection grips,
- Vector3d offset, MoveGripPointsFlags bitFlags)
- {
- // We only take action when we get this call on a database resident entity
- // Dragging operation makes shallow clone of line,
- // and setting clomeMeForDragging to false is generally a bad idea.
- // (If you do set clone me for dragging to false, then don't call bae class overriden methods).
- if (entity.Id.IsValid)
- {
- // Cast to a Line so we can access properties
- Line myLine = (Line)entity;
- Vector3d lineDir = (myLine.EndPoint - myLine.StartPoint);
- lineDir = lineDir.GetNormal();
- // Direction of Line
- double offsetDist = lineDir.DotProduct(offset);
- // Component of mouse translation along like
- // Iterate through list of all grips being moved
- foreach (GripData g in grips)
- {
- if (g is MyGrip)
- {
- MyGrip grip = (MyGrip)g;
- // Cast to our grip type
- // Make sure offset never takes grip beyond either end of line
- if (offsetDist >= 0)
- {
- if (offsetDist > (myLine.EndPoint - grip.GripPoint).Length)
- {
- offsetDist = (myLine.EndPoint - grip.GripPoint).Length;
- }
- }
- else
- {
- if (-offsetDist > (myLine.StartPoint - grip.GripPoint).Length)
- {
- offsetDist = -(myLine.StartPoint - grip.GripPoint).Length;
- }
- }
- lineDir = lineDir * offsetDist;
- // retrieve stored data and edit the changed value
- ResultBuffer rb = HelperClass.GetSingleton.GetXRecordData(entity);
- TypedValue[] typeValue = rb.AsArray();
- String val1 = (String)typeValue[0].Value;
- int[] intVal = new int[3];
- intVal[0] = (int)typeValue[1].Value;
- // min
- intVal[1] = (int)typeValue[2].Value;
- // max
- intVal[2] = (int)typeValue[3].Value;
- // current
- // Tell grip to move itself long the line
- grip.Move(lineDir);
- // Calculate new temperature from grip position along the line
- double newParam = myLine.GetParameterAtPoint(grip.GripPoint);
- int newTemp = (int)(100 * (newParam - myLine.StartParam) / (myLine.EndParam - myLine.StartParam));
- // Don't let min temp value rise above max temp
- // And don't let max temp go below min temp
- if (grip.Ordinal == 0)
- {
- if (newTemp < intVal[1])
- {
- intVal[0] = newTemp;
- }
- else
- {
- intVal[0] = intVal[1] - 1;
- }
- }
- else if (grip.Ordinal == 1)
- {
- if (newTemp > intVal[0])
- {
- intVal[1] = newTemp;
- }
- else
- {
- intVal[1] = intVal[0] + 1;
- }
- }
- else
- {
- intVal[2] = newTemp;
- }
- // Create new resbuf with new data and put back in Xrecord
- ResultBuffer newRb = new ResultBuffer(new TypedValue((int)DxfCode.Text, val1),
- new TypedValue((int)DxfCode.Int32, intVal[0]),
- new TypedValue((int)DxfCode.Int32, intVal[1]),
- new TypedValue((int)DxfCode.Int32, intVal[2]));
- HelperClass.GetSingleton.SetXRecordData(myLine, newRb);
- }
- }
- }
- // Remove our grips from the list befroe calling base class function
- // (Doesn't seem to like my grips)
- for (int i = grips.Count - 1; i >= 0; i += -1)
- {
- if (grips[i] is MyGrip)
- {
- grips.Remove(grips[i]);
- }
- }
- // If any grips left, then we call base class function
- if (grips.Count > 0)
- {
- base.MoveGripPointsAt(entity, grips, offset, bitFlags);
- }
- }
- }
- #region "Simple DrawableOverrule "
- // This overrule adds our custom graphhics to the Line
- // We're going to turn our Line into a Thermometer
- public class MyDrawOverrule : DrawableOverrule
- {
- const int mSize = 30;
- // Universal scaling constant - so I don't have to edit every calculation
- // if I want the thermometer thicker or thinner
- // This is the function that gets called to add/replace an entity's WorldDraw graphics
- public override bool WorldDraw(Drawable drawable, WorldDraw wd)
- {
- // Is it a line? (It should be)
- if (!(drawable is Line))
- {
- return base.WorldDraw(drawable, wd);
- }
- Line myLine = (Line)drawable;
- Point3dCollection pts = new Point3dCollection();
- // Read Xrecord values to populate prompt defauls
- ResultBuffer resbuf = HelperClass.GetSingleton.GetXRecordData(myLine);
- TypedValue[] typeValue = resbuf.AsArray();
- // Room name
- String myText = (String)typeValue[0].Value;
- // Min temp
- int lowerTemp = (int)typeValue[1].Value;
- // max temp
- int upperTemp = (int)typeValue[2].Value;
- // Current temp
- int curTemp = (int)typeValue[3].Value;
- double curPos = curTemp / 100.0;
- Vector3d perpVec = (myLine.EndPoint - myLine.StartPoint).CrossProduct(myLine.Normal).GetNormal();
- double startParam = myLine.GetParameterAtPoint(myLine.StartPoint);
- double endParam = myLine.GetParameterAtPoint(myLine.EndPoint);
- var oldColIndex = wd.SubEntityTraits.Color;
- FillType oldFillType = wd.SubEntityTraits.FillType;
- double posParam = 0;
- IntPtr gsMarker = default(IntPtr);
- // Draw thermometer body
- wd.SubEntityTraits.FillType = FillType.FillNever;
- // right body edge
- pts.Clear();
- pts.Add(myLine.StartPoint + perpVec * myLine.Length * 2.5 / mSize);
- pts.Add(myLine.EndPoint + perpVec * myLine.Length * 2.5 / mSize);
- gsMarker = (System.IntPtr)1;
- wd.Geometry.Polyline(pts, myLine.Normal, gsMarker);
- // left body edge
- pts.Clear();
- pts.Add(myLine.EndPoint - perpVec * myLine.Length * 2.5 / mSize);
- pts.Add(myLine.StartPoint - perpVec * myLine.Length * 2.5 / mSize);
- gsMarker = (System.IntPtr)2;
- wd.Geometry.Polyline(pts, myLine.Normal, gsMarker);
- // top body edge
- wd.Geometry.CircularArc(myLine.EndPoint - perpVec * myLine.Length * 2.5 / mSize,
- myLine.EndPoint + (myLine.EndPoint - myLine.StartPoint) * 2.5 / mSize,
- myLine.EndPoint + perpVec * myLine.Length * 2.5 / mSize, ArcType.ArcSimple);
- // bottom body edge
- double theta = Math.PI / 6;
- double rad = (myLine.Length * 2.5 / mSize) / Math.Sin(theta);
- double a = (myLine.Length * 2.5 / mSize) / Math.Tan(theta);
- Point3d bowlCenter = myLine.StartPoint + (myLine.StartPoint - myLine.EndPoint).GetNormal() * a;
- wd.Geometry.CircularArc(myLine.StartPoint + perpVec * myLine.Length * 2.5 / mSize,
- myLine.StartPoint + (myLine.StartPoint - myLine.EndPoint).GetNormal() * (rad + a),
- myLine.StartPoint - perpVec * myLine.Length * 2.5 / mSize, ArcType.ArcSimple);
- // Draw upper temperature marker (in red)
- wd.SubEntityTraits.Color = 1;
- posParam = startParam + (endParam - startParam) * (upperTemp / 100.0);
- pts.Clear();
- pts.Add(myLine.GetPointAtParameter(posParam) - perpVec * myLine.Length * 3 / mSize);
- pts.Add(myLine.GetPointAtParameter(posParam) + perpVec * myLine.Length * 3 / mSize);
- gsMarker = (System.IntPtr)3;
- wd.Geometry.Polyline(pts, myLine.Normal, gsMarker);
- wd.Geometry.Text(myLine.GetPointAtParameter(posParam) + perpVec * myLine.Length * 4 / mSize,
- myLine.Normal, perpVec, myLine.Length * 1.2 / mSize, 1, 0,
- "Max. Temp = " + upperTemp.ToString());
- // Draw lower temperature marker (in blue)
- wd.SubEntityTraits.Color = 5;
- posParam = startParam + (endParam - startParam) * (lowerTemp / 100.0);
- pts.Clear();
- pts.Add(myLine.GetPointAtParameter(posParam) - perpVec * myLine.Length * 3 / mSize);
- pts.Add(myLine.GetPointAtParameter(posParam) + perpVec * myLine.Length * 3 / mSize);
- gsMarker = (System.IntPtr)3;
- wd.Geometry.Polyline(pts, myLine.Normal, gsMarker);
- wd.Geometry.Text(myLine.GetPointAtParameter(posParam) + perpVec * myLine.Length * 4 / mSize,
- myLine.Normal, perpVec, myLine.Length * 1.2 / mSize, 1, 0,
- "Min. Temp = " + lowerTemp.ToString());
- // Draw current temperature marker in different color depending on position w.r.t. min and max temps
- short colIndex = 0;
- if (curTemp <= lowerTemp)
- {
- colIndex = 5;
- // Blue
- }
- else if (curTemp >= upperTemp)
- {
- colIndex = 1;
- // Red
- }
- else
- {
- colIndex = 94;
- // Dark green
- }
- // Draw current Temperature marker
- wd.SubEntityTraits.Color = colIndex;
- posParam = startParam + (endParam - startParam) * (curTemp / 100.0);
- pts.Clear();
- pts.Add(myLine.GetPointAtParameter(posParam) - perpVec * myLine.Length * 3 / mSize);
- pts.Add(myLine.GetPointAtParameter(posParam) + perpVec * myLine.Length * 3 / mSize);
- gsMarker = (System.IntPtr)4;
- wd.Geometry.Polyline(pts, myLine.Normal, gsMarker);
- wd.Geometry.Text(myLine.GetPointAtParameter(posParam) + perpVec * myLine.Length * 4 / mSize,
- myLine.Normal, perpVec, myLine.Length * 1.2 / mSize, 1, 0,
- myText + " Temp = " + curTemp.ToString());
- // We want to draw filled primitives (polygon and circle) to
- // represent the mercury in the thermometer
- wd.SubEntityTraits.FillType = FillType.FillAlways;
- // drawable mercury - line first, then bowl
- pts.Clear();
- Vector3d offset = perpVec * myLine.Length / mSize;
- Point3d pt1 = myLine.StartPoint + offset;
- pts.Add(bowlCenter + offset);
- pts.Add(bowlCenter - offset);
- pts.Add(myLine.GetPointAtParameter(posParam) - offset);
- pts.Add(myLine.GetPointAtParameter(posParam) + offset);
- wd.Geometry.Polygon(pts);
- // mercury bowl
- theta = Math.PI / 6;
- rad = 1.5 * (offset.Length) / Math.Sin(theta);
- a = (offset.Length) / Math.Tan(theta);
- wd.Geometry.Circle(bowlCenter, rad, myLine.Normal);
- // Set old subentitytrait values, then call overriden class worlddraw fn
- wd.SubEntityTraits.FillType = oldFillType;
- wd.SubEntityTraits.Color = oldColIndex;
- return base.WorldDraw(drawable, wd);
- }
- }
- #endregion
- #region "Implementation of the commands"
- public class TestOverrule : IExtensionApplication
- {
- // Setup some global variables
- static MyDrawOverrule mDrawOverrule;
- // One and only instance of this DrawableOverrule
- static MyGripOverrule mGripOverrule;
- // One and only instance of this TransformOverrule
- // Called when DLL is loaded by AutoCAD.
- public void Initialize()
- {
- // Instantiate our global Overrule and set it to overrule lines with my data attached
- mDrawOverrule = new MyDrawOverrule();
- Overrule.AddOverrule(RXObject.GetClass(typeof(Line)), mDrawOverrule, false);
- mDrawOverrule.SetExtensionDictionaryEntryFilter(HelperClass.GetSingleton.DictionaryName);
- // Instantiate our global Overrule and set it to overrule lines with my data attached
- mGripOverrule = new MyGripOverrule();
- Overrule.AddOverrule(RXObject.GetClass(typeof(Line)), mGripOverrule, false);
- mGripOverrule.SetExtensionDictionaryEntryFilter(HelperClass.GetSingleton.DictionaryName);
- // Turn overruling on
- Overrule.Overruling = true;
- }
- // Clean up after ourselves.
- public void Terminate()
- {
- Overrule.RemoveOverrule(RXObject.GetClass(typeof(Line)), mDrawOverrule);
- mDrawOverrule = null;
- Overrule.RemoveOverrule(RXObject.GetClass(typeof(Line)), mGripOverrule);
- mDrawOverrule = null;
- }
- // Toggles all overrules on and off.
- [CommandMethod("testoff")]
- public void ToggleOverrule()
- {
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- Overrule.Overruling = !Overrule.Overruling;
- ed.WriteMessage("\n*** Overrule is now " + Overrule.Overruling.ToString() + " ***\n");
- ed.Regen();
- }
- // Demo of Extension Dictionary filter.
- // There's also an Xdata filter, but we won't demonstrate it here - its basically the same).
- // This command needs tidying up to use HelperClass functions for XData access. (Currently does its own thing).
- [CommandMethod("teston")]
- public void AddXDictFilter()
- {
- // Select a line
- Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
- PromptEntityOptions opts = new PromptEntityOptions("\nSelect a line to add Extension dictionary to:");
- opts.SetRejectMessage("\nSorry dude! That's not a line\n");
- opts.AddAllowedClass(typeof(Line), true);
- PromptEntityResult res = ed.GetEntity(opts);
- // Only continue if a circle was selected
- if (res.Status != PromptStatus.OK)
- {
- return;
- }
- // Open circle and make sure it has our dictionary in its extension dictionary
- ObjectId objId = res.ObjectId;
- Database db = objId.Database;
- using (Transaction tr = db.TransactionManager.StartTransaction())
- {
- Entity ent = (Entity)tr.GetObject(objId, OpenMode.ForRead);
- ObjectId extId = ent.ExtensionDictionary;
- // Create ext dict if necessary
- if (extId == ObjectId.Null)
- {
- ent.UpgradeOpen();
- ent.CreateExtensionDictionary();
- extId = ent.ExtensionDictionary;
- }
- // Open ext dict
- DBDictionary extDict = (DBDictionary)tr.GetObject(extId, OpenMode.ForWrite);
- // make sure we clone data when entity is cloned for dragging
- extDict.TreatElementsAsHard = true;
- // If it doesn't contain our dictionary, we add one
- PromptIntegerOptions temp1Opts = new PromptIntegerOptions("\nEnter Lower Temperature:");
- PromptIntegerOptions temp2Opts = new PromptIntegerOptions("\nEnter Upper Temperature:");
- PromptIntegerOptions temp3Opts = new PromptIntegerOptions("\nEnter Current Temperature:");
- PromptStringOptions nameOpts = new PromptStringOptions("\nEnter Name:");
- temp1Opts.LowerLimit = 0;
- temp1Opts.UpperLimit = 100;
- temp2Opts.LowerLimit = 0;
- temp2Opts.UpperLimit = 100;
- temp3Opts.LowerLimit = 0;
- temp1Opts.UpperLimit = 100;
- ObjectId xRecObjID;
- Xrecord xRec;
- DBDictionary myDict;
- if (!extDict.Contains(HelperClass.GetSingleton.XRecordName))
- {
- // If dict is not present, then we add it and set up default Xrec to be edited later
- extDict.UpgradeOpen();
- myDict = new DBDictionary();
- // make sure we clone data when entity is cloned for dragging
- myDict.TreatElementsAsHard = true;
- extDict.SetAt(HelperClass.GetSingleton.DictionaryName, myDict);
- tr.AddNewlyCreatedDBObject(myDict, true);
- temp1Opts.DefaultValue = 20;
- temp2Opts.DefaultValue = 30;
- temp3Opts.DefaultValue = 25;
- nameOpts.DefaultValue = "San Rafael";
- xRec = new Xrecord();
- xRec.Data = new ResultBuffer(new TypedValue((int)DxfCode.Text, nameOpts.DefaultValue),
- new TypedValue((int)DxfCode.Int32, temp1Opts.DefaultValue),
- new TypedValue((int)DxfCode.Int32, temp2Opts.DefaultValue),
- new TypedValue((int)DxfCode.Int32, temp3Opts.DefaultValue));
- xRecObjID = myDict.SetAt(HelperClass.GetSingleton.XRecordName, xRec);
- tr.AddNewlyCreatedDBObject(xRec, true);
- }
- else
- {
- // If dict exists, then we extract values from XRecord to populate default values from prompt
- // We're assuming that if my dictionary exists, then so will the XRecord in it.
- ObjectId dictId = extDict.GetAt(HelperClass.GetSingleton.DictionaryName);
- myDict = (DBDictionary)tr.GetObject(dictId, OpenMode.ForWrite, false);
- temp1Opts.DefaultValue = 20;
- temp1Opts.DefaultValue = 30;
- xRecObjID = myDict.GetAt(HelperClass.GetSingleton.XRecordName);
- xRec = (Xrecord)tr.GetObject(xRecObjID, OpenMode.ForRead, false);
- }
- // xRec now points to our XRecord, which is open for write.
- // Read Xrecord values to populate prompt defauls
- TypedValue[] typeValue = xRec.Data.AsArray();
- TypedValue val1 = typeValue[0];
- // Room name
- TypedValue val2 = typeValue[1];
- // Min temp
- TypedValue val3 = typeValue[2];
- // Max temp
- TypedValue val4 = typeValue[3];
- // Current temp
- nameOpts.DefaultValue = (String)val1.Value;
- temp1Opts.DefaultValue = (int)val2.Value;
- temp2Opts.DefaultValue = (int)val3.Value;
- temp3Opts.DefaultValue = (int)val4.Value;
- // Prompt for new values
- PromptResult nameRes = ed.GetString(nameOpts);
- if (nameRes.Status == PromptStatus.OK)
- {
- val1 = new TypedValue((int)DxfCode.Text, nameRes.StringResult);
- }
- PromptIntegerResult temp1Res = ed.GetInteger(temp1Opts);
- if (temp1Res.Status == PromptStatus.OK)
- {
- val2 = new TypedValue((int)DxfCode.Int32, temp1Res.Value);
- }
- PromptIntegerResult temp2Res = ed.GetInteger(temp2Opts);
- if (temp2Res.Status == PromptStatus.OK)
- {
- val3 = new TypedValue((int)DxfCode.Int32, temp2Res.Value);
- }
- PromptIntegerResult temp3Res = ed.GetInteger(temp3Opts);
- if (temp3Res.Status == PromptStatus.OK)
- {
- val4 = new TypedValue((int)DxfCode.Int32, temp3Res.Value);
- }
- // Now set Xrecord contents to new values
- xRec.Data = new ResultBuffer(val1, val2, val3, val4);
- tr.Commit();
- }
- // Display new results
- ed.Regen();
- }
- }
- #endregion
- }
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|