Skip to content

Commit

Permalink
添加开发模板
Browse files Browse the repository at this point in the history
  • Loading branch information
vlong638 committed Nov 14, 2017
1 parent bc97649 commit 598d870
Show file tree
Hide file tree
Showing 78 changed files with 1,650 additions and 282 deletions.
Binary file modified .vs/MyRevit/v14/.suo
Binary file not shown.
1 change: 1 addition & 0 deletions MouseHook/MouseHook.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
Binary file modified MouseHook/bin/Debug/MouseHook.exe
Binary file not shown.
Binary file modified MouseHook/bin/Debug/MouseHook.pdb
Binary file not shown.
Binary file modified MouseHook/obj/Debug/MouseHook.exe
Binary file not shown.
Binary file modified MouseHook/obj/Debug/MouseHook.pdb
Binary file not shown.
48 changes: 40 additions & 8 deletions MyRevit/MyRevit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
Expand Down Expand Up @@ -127,7 +127,22 @@
<ItemGroup>
<Compile Include="EarthWork\Command\EarthworkBlockCommand.cs" />
<Compile Include="MyTests\0906Construction\CreateModelText_Command.cs" />
<Compile Include="MyTests\0Base\VLViewModelBase.cs" />
<Compile Include="MyTests\Template\TemplateModel.cs" />
<Compile Include="MyTests\Template\TemplateSet.cs" />
<Compile Include="MyTests\Template\TemplateViewModel.cs" />
<Compile Include="MyTests\Template\TemplateWindow.xaml.cs">
<DependentUpon>TemplateWindow.xaml</DependentUpon>
</Compile>
<Compile Include="MyTests\PipeAttributesAnnotation\PAAModel.cs" />
<Compile Include="MyTests\PipeAttributesAnnotation\PAASet.cs" />
<Compile Include="MyTests\PipeAttributesAnnotation\PAAViewModel.cs" />
<Compile Include="MyTests\PipeAttributesAnnotation\PAAWindow.xaml.cs">
<DependentUpon>PAAWindow.xaml</DependentUpon>
</Compile>
<Compile Include="MyTests\VLBase\VLConstraints.cs" />
<Compile Include="MyTests\VLBase\VLStorable.cs" />
<Compile Include="MyTests\VLBase\VLViewModel.cs" />
<Compile Include="MyTests\VLBase\VLWindow.cs" />
<Compile Include="MyTests\0Commands\PipeAnnotationCommand.cs" />
<Compile Include="MyTests\BeamAlignToFloor\BeamAlignToFloorViewModel.cs" />
<Compile Include="MyTests\BeamAlignToFloor\Constraints.cs" />
Expand Down Expand Up @@ -157,11 +172,13 @@
<Compile Include="MyTests\CompoundStructureAnnotation\CompoundStructureAnnotationSet.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\CSAModel.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\CSAModelCollection.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\CSAViewModel.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\FamilySymbolHelper.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\VLSerialize.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\VLConstraints.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\VLModelBase.cs" />
<Compile Include="MyTests\VLBase\VLSerializable.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\VLConstraintsForCSA.cs" />
<Compile Include="MyTests\VLBase\VLModel.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\VLModelCollectionBase.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\VLViewModelBase.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\调研_关联更新类型结构属性.cs" />
<Compile Include="MyTests\CompoundStructureAnnotation\调研_获取类型结构属性.cs" />
<Compile Include="MyTests\PipeAnnotation\AnnotationConstaints.cs" />
Expand Down Expand Up @@ -318,6 +335,7 @@
<Compile Include="Utilities\GraphsDisplayer.cs" />
<Compile Include="Utilities\LogHelper.cs" />
<Compile Include="Utilities\MessageHelper.cs" />
<Compile Include="Utilities\MouseHookHelper.cs" />
<Compile Include="Utilities\PMSoftHelper.cs" />
<Compile Include="Utilities\Revit_Helper.cs" />
<Compile Include="Utilities\Revit_UIDocument_Helper.cs" />
Expand Down Expand Up @@ -379,6 +397,22 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Page Include="MyTests\Template\ResourceDictionary.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MyTests\Template\TemplateWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="MyTests\PipeAttributesAnnotation\PAAWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MyTests\PipeAttributesAnnotation\ResourceDictionary.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Content Include="AddIns\EarthWork.addin" />
Expand Down Expand Up @@ -409,9 +443,7 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<Folder Include="MyTests\PipeAttributesAnnotation\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
28 changes: 0 additions & 28 deletions MyRevit/MyTests/0Base/VLViewModelBase.cs

This file was deleted.

28 changes: 15 additions & 13 deletions MyRevit/MyTests/CompoundStructureAnnotation/CSAContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,24 @@ public static CSAModelCollection GetCollection(Document doc)
/// 保存Collection
/// </summary>
/// <param name="doc"></param>
public static void SaveCollection(Document doc, bool isSecondTry = false)
public static bool Save(Document doc)
{
if (Collection == null)
return;
return false;
var data = Collection.ToData();
DelegateHelper.DelegateTryCatch(
() =>
{
ExtensibleStorageHelper.SetData(doc, CStorageEntity, CStorageEntity.FieldOfData, data);
},
() =>
{
ExtensibleStorageHelper.RemoveStorage(doc, CStorageEntity);
ExtensibleStorageHelper.SetData(doc, CStorageEntity, CStorageEntity.FieldOfData, data);
}
);
return DelegateHelper.DelegateTryCatch(
() =>
{
ExtensibleStorageHelper.SetData(doc, CStorageEntity, CStorageEntity.FieldOfData, data);
return true;
},
() =>
{
ExtensibleStorageHelper.RemoveStorage(doc, CStorageEntity);
ExtensibleStorageHelper.SetData(doc, CStorageEntity, CStorageEntity.FieldOfData, data);
return false;
}
);
}
}
}
5 changes: 3 additions & 2 deletions MyRevit/MyTests/CompoundStructureAnnotation/CSAModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Autodesk.Revit.DB;
using MyRevit.MyTests.PipeAnnotationTest;
using MyRevit.MyTests.VLBase;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -12,7 +13,7 @@ namespace MyRevit.MyTests.CompoundStructureAnnotation
/// <summary>
/// CompoundStructureAnnotation数据的载体 详图线方案
/// </summary>
public class CSAModelForDetailLine : VLModelBase<CSAModel>
public class CSAModelForDetailLine : VLModel
{
public CSAModelForDetailLine(string data = "") : base(data)
{
Expand Down Expand Up @@ -306,7 +307,7 @@ public void CalculateLocations(Element element)
/// <summary>
/// CompoundStructureAnnotation数据的载体 线族方案
/// </summary>
public class CSAModel : VLModelBase<CSAModel>
public class CSAModel : VLModel
{
#region Construction
public CSAModel() : base("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public CSAModelCollection(string data) : base(data)
/// <param name="doc"></param>
public void Save(Document doc)
{
CSAContext.SaveCollection(doc);
CSAContext.Save(doc);
}
}

}
147 changes: 147 additions & 0 deletions MyRevit/MyTests/CompoundStructureAnnotation/CSAViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using MyRevit.MyTests.Utilities;
using MyRevit.MyTests.VLBase;
using MyRevit.Utilities;
using PmSoft.Optimization.DrawingProduction;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Interop;

namespace MyRevit.MyTests.CompoundStructureAnnotation
{
/// <summary>
/// CompoundStructureAnnotation ViewModel
/// </summary>
public class CSAViewModel : VLViewModel<CSAModel,CompoundStructureAnnotationWindow>
{
public CSAViewModel(UIApplication app) : base(app)
{
Model = new CSAModel();
LocationType = CSALocationType.OnEdge;
}

public CSAViewType ViewType { set; get; }
public CSAModel Model { set; get; }

#region 绑定用属性 需在ViewModel中初始化
CSALocationType LocationType
{
get
{
return Model.CSALocationType;
}
set
{
Model.CSALocationType = value;
RaisePropertyChanged("IsDocument");
RaisePropertyChanged("IsLinkDocument");
}
}
public bool IsOnLine
{
get { return LocationType == CSALocationType.OnLine; }
set { if (value) LocationType = CSALocationType.OnLine; }
}
public bool IsOnEdge
{
get { return LocationType == CSALocationType.OnEdge; }
set { if (value) LocationType = CSALocationType.OnEdge; }
}

public List<TextNoteType> TextNoteTypes { get { return Model.GetTextNoteTypes(); } }
public ElementId TextNoteTypeElementId
{
get
{
if (Model.TextNoteTypeElementId == null)
{
Model.TextNoteTypeElementId = TextNoteTypes.FirstOrDefault().Id;
}
return Model.TextNoteTypeElementId;
}
set
{
Model.TextNoteTypeElementId = value;
this.RaisePropertyChanged("Type");
}
}

public override bool CanClose
{
get
{
return ViewType == CSAViewType.Idle;
}
}
#endregion

public override void Execute()
{
switch (ViewType)
{
case CSAViewType.Idle:
View = new CompoundStructureAnnotationWindow(this);
IntPtr rvtPtr = Autodesk.Windows.ComponentManager.ApplicationWindow;
WindowInteropHelper helper = new WindowInteropHelper(View);
helper.Owner = rvtPtr;
View.ShowDialog();
break;
case CSAViewType.Select:
if (View.IsActive)
View.Close();
using (PmSoft.Common.RevitClass.PickObjectsMouseHook MouseHook = new PmSoft.Common.RevitClass.PickObjectsMouseHook())
{
MouseHook.InstallHook(PmSoft.Common.RevitClass.PickObjectsMouseHook.OKModeENUM.Objects);
try
{
Model.TargetId = UIDocument.Selection.PickObject(ObjectType.Element
, new ClassesFilter(false, typeof(Wall), typeof(Floor), typeof(ExtrusionRoof), typeof(FootPrintRoof))).ElementId;
MouseHook.UninstallHook();
ViewType = CSAViewType.Generate;
}
catch (Exception ex)
{
MouseHook.UninstallHook();
ViewType = CSAViewType.Idle;
}
}
break;
case CSAViewType.Generate:
var doc = UIDocument.Document;
if (TransactionHelper.DelegateTransaction(doc, "生成结构标注", (Func<bool>)(() =>
{
var element = doc.GetElement(Model.TargetId);
var Collection = CSAContext.GetCollection(doc);
//避免重复生成 由于一个对象可能在不同的视图中进行标注设置 所以还是需要重复生成的
var existedModel = Collection.Data.FirstOrDefault(c => c.TargetId.IntegerValue == Model.TargetId.IntegerValue);
if (existedModel != null)
{
Collection.Data.Remove(existedModel);
CSAContext.Creater.Clear(doc, existedModel);
}
CSAContext.Creater.Generate(doc, Model, element);
Collection.Data.Add(Model);
Collection.Save(doc);
return true;
})))
ViewType = CSAViewType.Select;
else
ViewType = CSAViewType.Idle;
break;
case CSAViewType.Close:
View.Close();
break;
default:
break;
}
}

public override void Close()
{
ViewType = CSAViewType.Close;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class CompoundStructureAnnotationSet : OptimizationCToolCmd
public CompoundStructureAnnotationSet(UIApplication app) : base(app)
{
Init(app);
ViewModel = new CSAViewModel();
ViewModel = new CSAViewModel(app);
}

/// <summary>
Expand All @@ -58,11 +58,12 @@ protected override bool DoUI()
VLConstraintsForCSA.Doc = doc;
try
{
CompoundStructureAnnotationWindow window = new CompoundStructureAnnotationWindow(this);
while (ViewModel.ViewType != CSAViewType.Close)
{
ViewModel.Execute(window, this, uiDoc);
}
CompoundStructureAnnotationWindow window = new CompoundStructureAnnotationWindow(ViewModel);
ViewModel.Execute();
//while (ViewModel.ViewType != CSAViewType.Close)
//{
// ViewModel.Execute(window, this, uiDoc);
//}
return true;
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Execute(UpdaterData updateData)
}
}
if (isDeleted)
CSAContext.SaveCollection(doc);
CSAContext.Save(doc);
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public void Execute(UpdaterData updateData)
}
#endregion
}
CSAContext.SaveCollection(document);
CSAContext.Save(document);
}
catch (Exception ex)
{
Expand Down
Loading

0 comments on commit 598d870

Please sign in to comment.