79 lines
2.8 KiB
C#
79 lines
2.8 KiB
C#
using Autodesk.Revit.UI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.UI.Selection;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace KMBIM.Revit.Tools.Cmd.Parameter
|
|
{
|
|
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
|
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
|
[Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
|
|
public class CopyParameterCommand : IExternalCommand
|
|
{
|
|
private UIApplication uiapp = null;
|
|
private UIDocument uidoc = null;
|
|
private Autodesk.Revit.ApplicationServices.Application app = null;
|
|
private Document doc = null;
|
|
|
|
|
|
List<Element> selectedElement = null;
|
|
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
|
|
{
|
|
try
|
|
{
|
|
if (!WorkMain.GetInstance().IsValid) return Autodesk.Revit.UI.Result.Succeeded;
|
|
Element eSrc = null;
|
|
|
|
// Verify active document
|
|
if (null == commandData.Application.ActiveUIDocument.Document)
|
|
{
|
|
message = "현재 활성화된 뷰가 없습니다.";
|
|
return Autodesk.Revit.UI.Result.Failed;
|
|
}
|
|
|
|
uiapp = commandData.Application;
|
|
uidoc = uiapp.ActiveUIDocument;
|
|
app = uiapp.Application;
|
|
doc = uidoc.Document;
|
|
|
|
|
|
// 선택한 패밀리요소로부터 파라미터를 복사합니다.
|
|
try
|
|
{
|
|
var r = uidoc.Selection.PickObject(ObjectType.Element, "파라미터를 복사할 기준 패밀리 선택.");
|
|
if (r == null) return Autodesk.Revit.UI.Result.Failed;
|
|
|
|
eSrc = doc.GetElement(r.ElementId);
|
|
if (eSrc != null)
|
|
{
|
|
FormSelectParameter wf = new FormSelectParameter(eSrc);
|
|
wf.ShowDialog();
|
|
}
|
|
|
|
}
|
|
catch (Autodesk.Revit.Exceptions.OperationCanceledException)
|
|
{
|
|
return Result.Cancelled;
|
|
}
|
|
|
|
if (eSrc != null)
|
|
{
|
|
// 파라미터 복사(리스트박스-다중선택)
|
|
FormSelectParameter wf = new FormSelectParameter(eSrc);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
message = ex.ToString();
|
|
return Autodesk.Revit.UI.Result.Failed;
|
|
}
|
|
|
|
return Autodesk.Revit.UI.Result.Succeeded;
|
|
}
|
|
}
|
|
}
|