using Laservall.Solidworks.Extension; using Laservall.Solidworks.Model; using Laservall.Solidworks.Pane.WPF; using SolidWorks.Interop.sldworks; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Xarial.XCad; using Xarial.XCad.Documents; using Xarial.XCad.Features; using Xarial.XCad.SolidWorks.Documents; using Xarial.XCad.SolidWorks.UI; namespace Laservall.Solidworks.Pane { /// /// PartPropPaneUserControl.xaml 的交互逻辑 /// public partial class PartPropPaneUserControl : UserControl { public ISwTaskPane pane; public PartPropModel PartPropModel { get; set; } = new PartPropModel(); public PartPropPaneUserControl() { InitializeComponent(); DataContext = this; VersionText.Text = $"Ver.{Assembly.GetExecutingAssembly().GetName().Version}"; } public void OnSelectChange(IXDocument doc, IXSelObject xSelObject) { if (xSelObject.OwnerDocument is IXDocument) { if(xSelObject is ISwPartComponent partComponent) { SWDocReader.ReadDocProperties((IModelDoc2)partComponent.Component.GetModelDoc(), PartPropModel); } else if(xSelObject is IXFeature feature) { if(feature.Component is ISwComponent swPartComponent) { var doc2 = swPartComponent.Component.GetModelDoc() as IModelDoc2; if(doc2 != null) { SWDocReader.ReadDocProperties(doc2, PartPropModel); } } else if(feature.OwnerDocument != null) { var doc2 = (feature.OwnerDocument as ISwDocument).Model; if (doc2 != null) { SWDocReader.ReadDocProperties(doc2, PartPropModel); } } } } if(xSelObject.OwnerDocument is ISwPart) { //xSelObject.OwnerDocument.Properties } Debug.WriteLine($"OnSelectChange: {xSelObject.GetType()}"); } } }