马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Is it possible to emulate command LIVESECTION with AutoCAD .NET API
This question is coming from one of our beloved Forum contributor and Mentor Alexander Rivilis
- I am working with code which change color of Intersection Fill of Live Section. But although the color is changed, but this is not visible on the screen until I turn off and turn LIVESECTION:
- I made slight changes to have this working
- Note: To work this make sure LIVESECTION is not turned on
- This code will change color of SECTION which converted to LIVESECTION
复制代码
- public void SetSectionColor()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- if (doc == null) return;
- Editor ed = doc.Editor;
- PromptEntityOptions peo =
- new PromptEntityOptions("\nSelect section: ");
- peo.SetRejectMessage("\nIt is not a section!");
- peo.AddAllowedClass(typeof(Section), true);
- PromptEntityResult per = ed.GetEntity(peo);
- if (per.Status != PromptStatus.OK) return;
- ObjectId idSecSets = ObjectId.Null;
- using (Transaction tr =
- doc.TransactionManager.StartOpenCloseTransaction())
- {
- Section sec =
- tr.GetObject(per.ObjectId,
- OpenMode.ForWrite) as Section;
- sec.IsLiveSectionEnabled = true;
- idSecSets = sec.Settings;
- tr.Commit();
- }
- using (Transaction tr = doc.TransactionManager
- .StartOpenCloseTransaction())
- {
- SectionSettings secset = tr.GetObject(idSecSets,
- OpenMode.ForWrite) as SectionSettings;
- secset.CurrentSectionType = SectionType.LiveSection;
- Color clr = secset.Color(SectionType.LiveSection,
- SectionGeometry.IntersectionFill);
- ColorDialog cd = new ColorDialog
- {
- Color = clr
- };
- System.Windows.Forms.DialogResult dr = cd.ShowDialog();
- if (dr != System.Windows.Forms.DialogResult.OK) return;
- ed.WriteMessage("\nSelected Color: " + cd.Color.ToString());
- clr = cd.Color;
- // Define that color we change
- secset.SetColor(SectionType.LiveSection,
- SectionGeometry.IntersectionFill, clr);
- tr.Commit();
- }
- }
Gif
|