public static PointSet getPointFromText(ScaleProp scale) { Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; try { PointSet pointSet = new PointSet(); TypedValue[] filter = null; filter = new TypedValue[] { new TypedValue(0, "TEXT") }; PromptSelectionResult selection = editor.SelectAll(new SelectionFilter(filter)); if (selection.Status == (PromptStatus)(-5002)) { CommandLineQuerries.OnCancelled(); } if (selection.Status != (PromptStatus)5100) { return(null); } ObjectId[] objectIDs = selection.Value.GetObjectIds(); if (objectIDs != null) { Database workingDatabase = HostApplicationServices.WorkingDatabase; using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction()) { for (int i = 0; i < objectIDs.Length; i++) { DBText dbText = (DBText)transaction.GetObject(objectIDs[i], OpenMode.ForRead, true); string text = dbText.TextString; double z = 0; double.TryParse(text, out z); pointSet.Add(new ngeometry.VectorGeometry.Point(dbText.Position.X * scale.X, dbText.Position.Y * scale.Y, z * scale.Z)); } transaction.Commit(); } } else { editor.WriteMessage("没有选择到点.\n"); } return(pointSet); } catch (System.Exception ex) { } return(null); }
public override object ConvertFrom( ITypeDescriptorContext context, CultureInfo info, object value) { ScaleProp p = null; if (value is string) { try { string s = (string)value; // parse the format "Last, First (Age)" // int comma = s.IndexOf(','); if (comma != -1) { // now that we have the comma, get // the last name. string last = s.Substring(0, comma); int paren = s.LastIndexOf('('); if (paren != -1 && s.LastIndexOf(')') == s.Length - 1) { // pick up the first name string first = s.Substring(comma + 1, paren - comma - 1); // get the age int age = Int32.Parse( s.Substring(paren + 1, s.Length - paren - 2)); p = new ScaleProp(); return(p); } } } catch (System.Exception ex) { } // if we got this far, complain that we // couldn't parse the string // throw new ArgumentException( "Can not convert '" + (string)value + "' to type Person"); } p = new ScaleProp(); return(p); return(base.ConvertFrom(context, info, value)); }
public TCSettings() { Scale = new ScaleProp(); FaceColorList2 = new ColorProp(); /*FaceColorList2.colorList = new List<Color>{ * Color.FromArgb(255,0,0), * Color.FromArgb(126,0,0), * Color.FromArgb(0,126,0), * Color.FromArgb(0,255,0), * Color.FromArgb(0,0,125), * Color.FromArgb(0,0,255) * };*/ FaceColorList2.colorList = ColorizeBase.genColorList(colorCount); ContourFont = new Font(FontFamily.GenericSerif, 11); }
public override object ConvertTo( ITypeDescriptorContext context, CultureInfo culture, object value, Type destType) { ScaleProp p = null; if (destType == typeof(string) && value is ScaleProp) { p = (ScaleProp)value; return(p.ToString()); } p = new ScaleProp(); return(p.ToString()); return(base.ConvertTo(context, culture, value, destType)); }