Skip to content

Commit

Permalink
1.添加安装文件;2.修复ISketch.IModelToSketchXform不支持托管代码的bug;3.修复base64编码错误;
Browse files Browse the repository at this point in the history
  • Loading branch information
weianweigan committed Dec 29, 2020
1 parent 29a5320 commit c489b2b
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 58 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ bld/
[Ll]og/
[Ll]ogs/

# Advanced Installer Build results
Setup Files/
*cache/

# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
Expand Down
Binary file added Installer/BrowseData_16x.ico
Binary file not shown.
187 changes: 149 additions & 38 deletions Installer/SolidWorksLookup.aip

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions SldWorksLookup/AddIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ private void CmdGroup_CommandClick(Command_e spec)

private void GetObject()
{
var doc = Application.Documents.Active;
var doc = Application.Sw.IActiveDoc2;
if (doc == null)
{
Application.ShowMessageBox($"No active doc");
}
var getObjectVM = new GetObjectByPIDWindowViewModel(doc.Model, this.Application);
var getObjectVM = new GetObjectByPIDWindowViewModel(doc, this.Application);
var window = CreatePopupWindow<GetObjectByPIDWindow>();
window.Control.VM = getObjectVM;
window.Show();
Expand Down
2 changes: 1 addition & 1 deletion SldWorksLookup/Helper/TypeNameToDefinitionUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static List<Type> Match(string typeName)
case "LocalSketchPattern": featDataTypes.Add(typeof(ILocalSketchPatternFeatureData)); break;
case "LPattern": featDataTypes.Add(typeof(ILinearPatternFeatureData)); break;
case "MacroFeature": featDataTypes.Add(typeof(IMacroFeatureData)); break;
case "MirrorCompFeat": throw new InvalidOperationException("IMirrorComponentFeatureData Can not Get in SolidWorks.Interop.SldWorks")/*featDataTypes.Add(typeof(IMirrorComponentFeatureData))*/; break;
case "MirrorCompFeat": throw new InvalidOperationException("IMirrorComponentFeatureData Can not Get in SolidWorks.Interop.SldWorks")/*featDataTypes.Add(typeof(IMirrorComponentFeatureData)); break;*/;
case "MirrorPattern": featDataTypes.Add(typeof(IMirrorPatternFeatureData)); break;
case "MirrorSolid": featDataTypes.Add(typeof(IMirrorSolidFeatureData)); break;
case "MirrorStock": featDataTypes.Add(typeof(IMirrorPartFeatureData)); break;
Expand Down
20 changes: 20 additions & 0 deletions SldWorksLookup/Model/Instance/ISketchInstanceProperty.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SldWorksLookup.Model
{
internal class ISketchInstanceProperty : InstanceProperty
{
public ISketchInstanceProperty(object instance, Type type, bool init = true) : base(instance, type, init)
{
}

protected override void InitUnSupportedMember()
{
_notSupportedMembers.Add(new NotSupportedMember("IModelToSketchXform", PropertyClsfi.Property, NOTSUPPORTMEMBER));
}
}
}
10 changes: 10 additions & 0 deletions SldWorksLookup/Model/Instance/InstanceProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ protected InstanceProperty(object instance, Type type,bool init = true)
}
}

/// <summary>
/// 创建描述此类型的实例对象
/// </summary>
/// <param name="instance">实例</param>
/// <param name="type">类型</param>
/// <param name="init">是否初始化</param>
/// <returns><see cref="InstanceProperty"/>类型</returns>
public static InstanceProperty Create(object instance,Type type,bool init = true)
{
InstanceProperty instanceProperty;
Expand All @@ -89,6 +96,9 @@ public static InstanceProperty Create(object instance,Type type,bool init = true
case nameof(ISurface):
instanceProperty = new ISurfaceInstanceProperty(instance, type, init);
break;
case nameof(ISketch):
instanceProperty = new ISketchInstanceProperty(instance, type, init);
break;
default:
instanceProperty = new InstanceProperty(instance, type, init);
break;
Expand Down
4 changes: 2 additions & 2 deletions SldWorksLookup/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.1.0")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyVersion("0.0.2.0")]
[assembly: AssemblyFileVersion("0.0.2.0")]
1 change: 1 addition & 0 deletions SldWorksLookup/SldWorksLookup.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<Compile Include="Model\Instance\IFace2InstanceProperty.cs" />
<Compile Include="Model\Instance\IMathTransformInstanceProperty.cs" />
<Compile Include="Model\Instance\InstanceProperty.cs" />
<Compile Include="Model\Instance\ISketchInstanceProperty.cs" />
<Compile Include="Model\Instance\ISurfaceInstanceProperty.cs" />
<Compile Include="Model\Instance\NotSupportedMember.cs" />
<Compile Include="Model\SelectionPID.cs" />
Expand Down
2 changes: 1 addition & 1 deletion SldWorksLookup/View/LookupPropertyWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:model="clr-namespace:SldWorksLookup.Model"
mc:Ignorable="d"
Height ="700" Width="700" Title="SolidWorks Lookup 0.0.1">
Height ="700" Width="700" Title="SolidWorks Lookup 0.0.2">
<Window.Resources>
<ResourceDictionary Source="pack://application:,,,/SldWorksLookup;component/WpfResource.xaml"/>
</Window.Resources>
Expand Down
35 changes: 21 additions & 14 deletions SldWorksLookup/ViewModel/GetObjectByPIDWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,27 +35,34 @@ public string PID

private void GetObjectClick()
{
var byteId = Convert.FromBase64String(PID);
var obj = _doc.Extension.GetObjectByPersistReference3(byteId, out int errorCode);
var errorCodeEnum = (swPersistReferencedObjectStates_e)errorCode;
if (obj == null)
try
{
_application.ShowMessageBox($"Cannot get object by PID, {errorCodeEnum.ToString()}");
}
else
{
var matchtype = PIDComObjectMatcherUtil.Match(obj);
if (matchtype != null)
var byteId = Convert.FromBase64String(PID);
var obj = _doc.Extension.GetObjectByPersistReference3(byteId, out int errorCode);
var errorCodeEnum = (swPersistReferencedObjectStates_e)errorCode;
if (obj == null)
{
var insPro = InstanceProperty.Create(obj, matchtype);
var window = new LookupPropertyWindow(insPro);
window.Show();
_application.ShowMessageBox($"Cannot get object by PID, {errorCodeEnum.ToString()}");
}
else
{
_application.ShowMessageBox($"{obj.GetType().FullName} cannot get a type, {errorCodeEnum.ToString()}");
var matchtype = PIDComObjectMatcherUtil.Match(obj);
if (matchtype != null)
{
var insPro = InstanceProperty.Create(obj, matchtype);
var window = new LookupPropertyWindow(insPro);
window.Show();
}
else
{
_application.ShowMessageBox($"{obj.GetType().FullName} cannot get a type, {errorCodeEnum.ToString()}");
}
}
}
catch (Exception ex)
{
_application.ShowMessageBox(ex.Message);
}
}

private bool CanGetObject()
Expand Down

0 comments on commit c489b2b

Please sign in to comment.