mirror of
https://github.com/jeremytammik/RevitSdkSamples.git
synced 2026-09-20 02:49:58 +00:00
added Revit 2020 SDK files
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using System.Diagnostics;
|
||||
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is the entrance of this project, it implements IExternalCommand.
|
||||
/// </summary>
|
||||
[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 Command : IExternalCommand
|
||||
{
|
||||
#region IExternalCommand Members
|
||||
|
||||
/// <summary>
|
||||
/// Implement this method as an external command for Revit.
|
||||
/// </summary>
|
||||
/// <param name="commandData">An object that is passed to the external application
|
||||
/// which contains data related to the command,
|
||||
/// such as the application object and active view.</param>
|
||||
/// <param name="message">A message that can be set by the external application
|
||||
/// which will be displayed if a failure or cancellation is returned by
|
||||
/// the external command.</param>
|
||||
/// <param name="elements">A set of elements to which the external application
|
||||
/// can add elements that are to be highlighted in case of failure or cancellation.</param>
|
||||
/// <returns>Return the status of the external command.
|
||||
/// A result of Succeeded means that the API external method functioned as expected.
|
||||
/// Cancelled can be used to signify that the user cancelled the external operation
|
||||
/// at some point. Failure should be returned if the application is unable to proceed with
|
||||
/// the operation.</returns>
|
||||
public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData,
|
||||
ref string message, Autodesk.Revit.DB.ElementSet elements)
|
||||
{
|
||||
try
|
||||
{
|
||||
CreationMgr mgr = new CreationMgr(commandData.Application.ActiveUIDocument);
|
||||
mgr.Execute();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
message += e.StackTrace;
|
||||
return Autodesk.Revit.UI.Result.Cancelled;
|
||||
}
|
||||
|
||||
return Autodesk.Revit.UI.Result.Succeeded;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the manager of all hosted sweep creators, it contains all the creators
|
||||
/// and each creator can create the corresponding hosted sweep. Its "Execute"
|
||||
/// method will show the main dialog for user to create hosted sweeps.
|
||||
/// </summary>
|
||||
public class CreationMgr
|
||||
{
|
||||
/// <summary>
|
||||
/// Revit active document.
|
||||
/// </summary>
|
||||
private Autodesk.Revit.UI.UIDocument m_rvtDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Creator for Fascia.
|
||||
/// </summary>
|
||||
private FasciaCreator m_fasciaCreator;
|
||||
|
||||
/// <summary>
|
||||
/// Creator for Gutter.
|
||||
/// </summary>
|
||||
private GutterCreator m_gutterCreator;
|
||||
|
||||
/// <summary>
|
||||
/// Creator for SlabEdge.
|
||||
/// </summary>
|
||||
private SlabEdgeCreator m_slabEdgeCreator;
|
||||
|
||||
/// <summary>
|
||||
/// Gets Fascia creator.
|
||||
/// </summary>
|
||||
public FasciaCreator FasciaCreator
|
||||
{
|
||||
get
|
||||
{
|
||||
if(m_fasciaCreator == null)
|
||||
{
|
||||
m_fasciaCreator = new FasciaCreator(m_rvtDoc);
|
||||
}
|
||||
return m_fasciaCreator;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets Gutter creator.
|
||||
/// </summary>
|
||||
public GutterCreator GutterCreator
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_gutterCreator == null)
|
||||
{
|
||||
m_gutterCreator = new GutterCreator(m_rvtDoc);
|
||||
}
|
||||
return m_gutterCreator;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets SlabEdge creator.
|
||||
/// </summary>
|
||||
public SlabEdgeCreator SlabEdgeCreator
|
||||
{
|
||||
get
|
||||
{
|
||||
if(m_slabEdgeCreator == null)
|
||||
{
|
||||
m_slabEdgeCreator = new SlabEdgeCreator(m_rvtDoc);
|
||||
}
|
||||
return m_slabEdgeCreator;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="rvtDoc">Revit active document</param>
|
||||
public CreationMgr(Autodesk.Revit.UI.UIDocument rvtDoc)
|
||||
{
|
||||
m_rvtDoc = rvtDoc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the main form, it is the UI entry.
|
||||
/// </summary>
|
||||
public void Execute()
|
||||
{
|
||||
using(MainForm mainForm = new MainForm(this))
|
||||
{
|
||||
mainForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using Autodesk.Revit;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functions to create Fascia.
|
||||
/// </summary>
|
||||
public class FasciaCreator : HostedSweepCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor which take Revit.Document as parameter.
|
||||
/// </summary>
|
||||
/// <param name="rvtDoc">Revit document</param>
|
||||
public FasciaCreator(Autodesk.Revit.UI.UIDocument rvtDoc)
|
||||
: base(rvtDoc)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary to store the roof=>edges for fascia creation.
|
||||
/// </summary>
|
||||
private Dictionary<Autodesk.Revit.DB.Element, List<Edge>> m_roofFasciaEdges;
|
||||
|
||||
/// <summary>
|
||||
/// Filter all the edges of the given element for fascia creation.
|
||||
/// </summary>
|
||||
/// <param name="elem">Element used to filter edges which fascia can be created on</param>
|
||||
private void FilterEdgesForFascia(Autodesk.Revit.DB.Element elem)
|
||||
{
|
||||
Transaction transaction = new Transaction(this.RvtDocument, "FilterEdgesForFascia");
|
||||
transaction.Start();
|
||||
|
||||
// Note: This method will create a Fascia with no references.
|
||||
// In the future, API may not allow to create such Fascia with
|
||||
// no references, invoke this methods like this may throw exception.
|
||||
//
|
||||
Fascia fascia = m_rvtDoc.Create.NewFascia(null, new ReferenceArray());
|
||||
|
||||
List<Edge> roofEdges = m_roofFasciaEdges[elem];
|
||||
foreach (Edge edge in m_elemGeom[elem].EdgeBindingDic.Keys)
|
||||
{
|
||||
if (edge.Reference == null) continue;
|
||||
try
|
||||
{
|
||||
fascia.AddSegment(edge.Reference);
|
||||
// AddSegment successfully, so this edge can be used to crate Fascia.
|
||||
roofEdges.Add(edge);
|
||||
}
|
||||
catch (Autodesk.Revit.Exceptions.ArgumentOutOfRangeException)
|
||||
{
|
||||
// Exception, this edge will be discard.
|
||||
}
|
||||
}
|
||||
// Delete this element, because we just use it to filter the edges.
|
||||
m_rvtDoc.Delete(fascia.Id);
|
||||
|
||||
transaction.RollBack();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string indicates this creator just for Roof Fascia creation.
|
||||
/// </summary>
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Roof Fascia";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All fascia types in Revit active document.
|
||||
/// </summary>
|
||||
public override IEnumerable AllTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(m_rvtDoc);
|
||||
filteredElementCollector.OfClass(typeof(FasciaType));
|
||||
return filteredElementCollector;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary to store all the Roof=>Edges which Fascia can be created on.
|
||||
/// </summary>
|
||||
public override Dictionary<Autodesk.Revit.DB.Element, List<Edge>> SupportEdges
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_roofFasciaEdges == null)
|
||||
{
|
||||
m_roofFasciaEdges = new Dictionary<Autodesk.Revit.DB.Element, List<Edge>>();
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_rvtDoc);
|
||||
collector.OfClass(typeof(FootPrintRoof));
|
||||
IList<Element> elements = collector.ToElements();
|
||||
|
||||
collector = new FilteredElementCollector(m_rvtDoc);
|
||||
collector.OfClass(typeof(ExtrusionRoof));
|
||||
foreach (Element elem in collector)
|
||||
{
|
||||
elements.Add(elem);
|
||||
}
|
||||
|
||||
foreach (Element elem in elements)
|
||||
{
|
||||
if (elem is RoofBase)
|
||||
{
|
||||
ElementGeometry solid = ExtractGeom(elem);
|
||||
if (solid != null)
|
||||
{
|
||||
m_roofFasciaEdges.Add(elem, new List<Edge>());
|
||||
m_elemGeom.Add(elem, solid);
|
||||
FilterEdgesForFascia(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_roofFasciaEdges;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Fascia.
|
||||
/// </summary>
|
||||
/// <param name="symbol">Fascia type</param>
|
||||
/// <param name="refArr">Fascia reference array</param>
|
||||
/// <returns>Created Fascia</returns>
|
||||
protected override HostedSweep CreateHostedSweep(ElementType symbol, ReferenceArray refArr)
|
||||
{
|
||||
Fascia fascia = m_rvtDoc.Create.NewFascia(symbol as FasciaType, refArr);
|
||||
|
||||
return fascia;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using Autodesk.Revit;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functions to create Gutter.
|
||||
/// </summary>
|
||||
public class GutterCreator : HostedSweepCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor with Revit.Document as parameter.
|
||||
/// </summary>
|
||||
/// <param name="rvtDoc">Revit document</param>
|
||||
public GutterCreator(Autodesk.Revit.UI.UIDocument rvtDoc)
|
||||
: base(rvtDoc)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edges which gutter can be created on.
|
||||
/// </summary>
|
||||
private Dictionary<Autodesk.Revit.DB.Element, List<Edge>> m_roofGutterEdges;
|
||||
|
||||
/// <summary>
|
||||
/// Filter all the edges from the element which gutter can be created on.
|
||||
/// </summary>
|
||||
/// <param name="elem"></param>
|
||||
private void FilterEdgesForGutter(Autodesk.Revit.DB.Element elem)
|
||||
{
|
||||
Transaction transaction = new Transaction(this.RvtDocument, "FilterEdgesForGutter");
|
||||
transaction.Start();
|
||||
|
||||
// Note: This method will create a Gutter with no reference.
|
||||
// In the future, API may not allow to create such Gutter with
|
||||
// no references, invoke this methods like this may throw exception.
|
||||
//
|
||||
Gutter gutter = m_rvtDoc.Create.NewGutter(null, new ReferenceArray());
|
||||
|
||||
List<Edge> roofEdges = m_roofGutterEdges[elem];
|
||||
foreach (Edge edge in m_elemGeom[elem].EdgeBindingDic.Keys)
|
||||
{
|
||||
if (edge.Reference == null) continue;
|
||||
try
|
||||
{
|
||||
gutter.AddSegment(edge.Reference);
|
||||
// AddSegment successfully, so this edge can be used to crate Gutter.
|
||||
roofEdges.Add(edge);
|
||||
}
|
||||
catch (Autodesk.Revit.Exceptions.ArgumentOutOfRangeException)
|
||||
{
|
||||
// Exception, this edge will be discard.
|
||||
}
|
||||
}
|
||||
// Delete this element, because we just use it to filter the edges.
|
||||
m_rvtDoc.Delete(gutter.Id);
|
||||
|
||||
transaction.RollBack();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string indicates this creator just for Roof Gutter creation.
|
||||
/// </summary>
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Roof Gutter";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All Gutter types in Revit active document.
|
||||
/// </summary>
|
||||
public override IEnumerable AllTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(m_rvtDoc);
|
||||
filteredElementCollector.OfClass(typeof(GutterType));
|
||||
return filteredElementCollector;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary to store all the Roof=>Edges which Gutter can be created on.
|
||||
/// </summary>
|
||||
public override Dictionary<Autodesk.Revit.DB.Element, List<Edge>> SupportEdges
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_roofGutterEdges == null)
|
||||
{
|
||||
m_roofGutterEdges = new Dictionary<Autodesk.Revit.DB.Element, List<Edge>>();
|
||||
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_rvtDoc);
|
||||
collector.OfClass(typeof(FootPrintRoof));
|
||||
IList<Element> elements = collector.ToElements();
|
||||
|
||||
collector = new FilteredElementCollector(m_rvtDoc);
|
||||
collector.OfClass(typeof(ExtrusionRoof));
|
||||
foreach (Element elem in collector)
|
||||
{
|
||||
elements.Add(elem);
|
||||
}
|
||||
|
||||
foreach (Element elem in elements)
|
||||
{
|
||||
if (elem is RoofBase)
|
||||
{
|
||||
ElementGeometry solid = ExtractGeom(elem);
|
||||
if (solid != null)
|
||||
{
|
||||
m_roofGutterEdges.Add(elem, new List<Edge>());
|
||||
m_elemGeom.Add(elem, solid);
|
||||
FilterEdgesForGutter(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_roofGutterEdges;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a Gutter.
|
||||
/// </summary>
|
||||
/// <param name="symbol">Gutter type</param>
|
||||
/// <param name="refArr">Gutter Reference array</param>
|
||||
/// <returns>Created Gutter</returns>
|
||||
protected override HostedSweep CreateHostedSweep(ElementType symbol, ReferenceArray refArr)
|
||||
{
|
||||
Gutter gutter = m_rvtDoc.Create.NewGutter(symbol as GutterType, refArr);
|
||||
return gutter;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,215 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functions to create hosted sweep and preserves available edges and type.
|
||||
/// It is the base class of FasciaCreator, GutterCreator, and SlabEdgeCreator.
|
||||
/// </summary>
|
||||
public abstract class HostedSweepCreator
|
||||
{
|
||||
#region Public Interfaces
|
||||
|
||||
/// <summary>
|
||||
/// A string indicates which type this creator can create.
|
||||
/// </summary>
|
||||
virtual public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Hosted Sweep";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A dictionary stores all the element=>edges which hosted-sweep can be created on.
|
||||
/// </summary>
|
||||
public abstract Dictionary<Autodesk.Revit.DB.Element, List<Edge>> SupportEdges
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All type of hosted-sweep.
|
||||
/// </summary>
|
||||
public abstract IEnumerable AllTypes
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A dictionary stores all the element=>geometry which hosted-sweep can be created on.
|
||||
/// </summary>
|
||||
public Dictionary<Autodesk.Revit.DB.Element, ElementGeometry> ElemGeomDic
|
||||
{
|
||||
get { return m_elemGeom; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a hosted-sweep according to the CreationData parameter.
|
||||
/// </summary>
|
||||
/// <param name="creationData">CreationData parameter</param>
|
||||
/// <returns>ModificationData which contains the created hosted-sweep</returns>
|
||||
public ModificationData Create(CreationData creationData)
|
||||
{
|
||||
ReferenceArray refArr = new ReferenceArray();
|
||||
foreach (Edge edge in creationData.EdgesForHostedSweep)
|
||||
{
|
||||
refArr.Append(edge.Reference);
|
||||
}
|
||||
|
||||
ModificationData modificationData = null;
|
||||
Transaction transaction = new Transaction(m_rvtDoc, "CreateHostedSweep");
|
||||
try
|
||||
{
|
||||
transaction.Start();
|
||||
HostedSweep createdHostedSweep = CreateHostedSweep(creationData.Symbol, refArr);
|
||||
|
||||
if (transaction.Commit() == TransactionStatus.Committed)
|
||||
{
|
||||
m_rvtUIDoc.ShowElements(createdHostedSweep);
|
||||
|
||||
// just only end transaction return true, we will create the hosted sweep.
|
||||
modificationData =
|
||||
new ModificationData(createdHostedSweep, creationData);
|
||||
m_createdHostedSweeps.Add(modificationData);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
transaction.RollBack();
|
||||
}
|
||||
return modificationData;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A list to store all the created hosted-sweep by this creator.
|
||||
/// </summary>
|
||||
public List<ModificationData> CreatedHostedSweeps
|
||||
{
|
||||
get { return m_createdHostedSweeps; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Revit active document.
|
||||
/// </summary>
|
||||
public Document RvtDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_rvtDoc;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Revit UI document.
|
||||
/// </summary>
|
||||
public UIDocument RvtUIDocument
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_rvtUIDoc;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Fields and Constructor
|
||||
/// <summary>
|
||||
/// List of Modification to store all the created hosted-sweep by this.
|
||||
/// </summary>
|
||||
private List<ModificationData> m_createdHostedSweeps;
|
||||
|
||||
/// <summary>
|
||||
/// Revit active document.
|
||||
/// </summary>
|
||||
protected Document m_rvtDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Revit UI document.
|
||||
/// </summary>
|
||||
protected UIDocument m_rvtUIDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary to store element's geometry which this creator can be used.
|
||||
/// </summary>
|
||||
protected Dictionary<Autodesk.Revit.DB.Element, ElementGeometry> m_elemGeom;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor which takes a Revit.Document as parameter.
|
||||
/// </summary>
|
||||
/// <param name="rvtDoc">Revit.Document parameter</param>
|
||||
protected HostedSweepCreator(Autodesk.Revit.UI.UIDocument rvtDoc)
|
||||
{
|
||||
m_rvtUIDoc = rvtDoc;
|
||||
m_rvtDoc = rvtDoc.Document;
|
||||
m_elemGeom = new Dictionary<Autodesk.Revit.DB.Element, ElementGeometry>();
|
||||
m_createdHostedSweeps = new List<ModificationData>();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// <summary>
|
||||
/// Create a hosted-sweep according to the given Symbol and ReferenceArray.
|
||||
/// </summary>
|
||||
/// <param name="symbol">Hosted-sweep Symbol</param>
|
||||
/// <param name="refArr">Hosted-sweep ReferenceArray</param>
|
||||
/// <returns>Created hosted-sweep</returns>
|
||||
protected abstract HostedSweep CreateHostedSweep(ElementType symbol, ReferenceArray refArr);
|
||||
|
||||
/// <summary>
|
||||
/// Extract the geometry of the given Element.
|
||||
/// </summary>
|
||||
/// <param name="elem">Element parameter</param>
|
||||
/// <returns>Element's geometry</returns>
|
||||
protected ElementGeometry ExtractGeom(Autodesk.Revit.DB.Element elem)
|
||||
{
|
||||
Solid result = null;
|
||||
Options options = new Options();
|
||||
options.ComputeReferences = true;
|
||||
Autodesk.Revit.DB.GeometryElement gElement = elem.get_Geometry(options);
|
||||
//foreach (GeometryObject gObj in gElement.Objects)
|
||||
IEnumerator<GeometryObject> Objects = gElement.GetEnumerator();
|
||||
while (Objects.MoveNext())
|
||||
{
|
||||
GeometryObject gObj = Objects.Current;
|
||||
|
||||
result = gObj as Solid;
|
||||
if (result != null && result.Faces.Size > 0)
|
||||
break;
|
||||
}
|
||||
BoundingBoxXYZ box = elem.get_BoundingBox(null);
|
||||
return new ElementGeometry(result, box);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,158 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides functions to create SlabEdge.
|
||||
/// </summary>
|
||||
public class SlabEdgeCreator : HostedSweepCreator
|
||||
{
|
||||
/// <summary>
|
||||
/// Constructor takes Revit.Document as parameter.
|
||||
/// </summary>
|
||||
/// <param name="rvtDoc">Revit document</param>
|
||||
public SlabEdgeCreator(Autodesk.Revit.UI.UIDocument rvtDoc)
|
||||
: base(rvtDoc)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edges which SlabEdge can be created on.
|
||||
/// </summary>
|
||||
private Dictionary<Autodesk.Revit.DB.Element, List<Edge>> m_floorSlabEdges;
|
||||
|
||||
/// <summary>
|
||||
/// Filter all the edges from the element which SlabEdge can be created on.
|
||||
/// </summary>
|
||||
/// <param name="elem"></param>
|
||||
private void FilterEdgesForSlabEdge(Autodesk.Revit.DB.Element elem)
|
||||
{
|
||||
Transaction transaction = new Transaction(this.RvtDocument, "FilterEdgesForSlabEdge");
|
||||
transaction.Start();
|
||||
|
||||
// Note: This method will create a SlabEdge with no reference.
|
||||
// In the future, API may not allow to create such SlabEdge with
|
||||
// no references, invoke this methods like this may throw exception.
|
||||
//
|
||||
SlabEdge slabEdge = m_rvtDoc.Create.NewSlabEdge(null, new ReferenceArray());
|
||||
|
||||
List<Edge> floorEdges = m_floorSlabEdges[elem];
|
||||
foreach (Edge edge in m_elemGeom[elem].EdgeBindingDic.Keys)
|
||||
{
|
||||
if (edge.Reference == null) continue;
|
||||
try
|
||||
{
|
||||
slabEdge.AddSegment(edge.Reference);
|
||||
// AddSegment successfully, so this edge can be used to crate SlabEdge.
|
||||
floorEdges.Add(edge);
|
||||
}
|
||||
catch (Autodesk.Revit.Exceptions.ArgumentOutOfRangeException)
|
||||
{
|
||||
// Exception, this edge will be discard.
|
||||
}
|
||||
}
|
||||
// Delete this element, because we just use it to filter the edges.
|
||||
m_rvtDoc.Delete(slabEdge.Id);
|
||||
|
||||
transaction.RollBack();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A string indicates this creator just for Floor SlabEdge creation.
|
||||
/// </summary>
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "Floor Slab Edge";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// All SlabEdge types in Revit active document.
|
||||
/// </summary>
|
||||
public override IEnumerable AllTypes
|
||||
{
|
||||
get
|
||||
{
|
||||
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(m_rvtDoc);
|
||||
filteredElementCollector.OfClass(typeof(SlabEdgeType));
|
||||
return filteredElementCollector;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a SlabEdge.
|
||||
/// </summary>
|
||||
/// <param name="symbol">SlabEdge type</param>
|
||||
/// <param name="refArr">SlabEdge reference array</param>
|
||||
/// <returns>Created SlabEdge</returns>
|
||||
protected override HostedSweep CreateHostedSweep(ElementType symbol, ReferenceArray refArr)
|
||||
{
|
||||
SlabEdge slabEdge = m_rvtDoc.Create.NewSlabEdge(symbol as SlabEdgeType, refArr);
|
||||
if (slabEdge != null)
|
||||
// Avoid the Revit warning, flip the direction in horizontal direction.
|
||||
slabEdge.HorizontalFlip();
|
||||
return slabEdge;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dictionary to store all the Floor=>Edges which SlabEdge can be created on.
|
||||
/// </summary>
|
||||
public override Dictionary<Autodesk.Revit.DB.Element, List<Edge>> SupportEdges
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_floorSlabEdges == null)
|
||||
{
|
||||
m_floorSlabEdges = new Dictionary<Autodesk.Revit.DB.Element, List<Edge>>();
|
||||
|
||||
FilteredElementCollector collector = new FilteredElementCollector(m_rvtDoc);
|
||||
collector.OfClass(typeof(Floor));
|
||||
foreach (Element elem in collector.ToElements())
|
||||
{
|
||||
if (elem is Floor)
|
||||
{
|
||||
ElementGeometry solid = ExtractGeom(elem);
|
||||
if (solid != null)
|
||||
{
|
||||
m_floorSlabEdges.Add(elem, new List<Edge>());
|
||||
m_elemGeom.Add(elem, solid);
|
||||
FilterEdgesForSlabEdge(elem);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_floorSlabEdges;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains the data for hosted sweep creation.
|
||||
/// </summary>
|
||||
public class CreationData
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the EdgeAdded or EdgeRemoved events
|
||||
/// of CreationData
|
||||
/// </summary>
|
||||
/// <param name="edge">Edge</param>
|
||||
public delegate void EdgeEventHandler(Edge edge);
|
||||
|
||||
/// <summary>
|
||||
/// Represents the method that will handle the SymbolChanged events
|
||||
/// of CreationData
|
||||
/// </summary>
|
||||
/// <param name="sym">Symbol</param>
|
||||
public delegate void SymbolChangedEventHandler(ElementType sym);
|
||||
|
||||
/// <summary>
|
||||
/// Edge is added to HostedSweep.
|
||||
/// </summary>
|
||||
public event EdgeEventHandler EdgeAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Edge is removed from HostedSweep.
|
||||
/// </summary>
|
||||
public event EdgeEventHandler EdgeRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep symbol is changed.
|
||||
/// </summary>
|
||||
public event SymbolChangedEventHandler SymbolChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Creator contains the necessary data to fetch the edges and get the symbol.
|
||||
/// </summary>
|
||||
private HostedSweepCreator m_creator;
|
||||
|
||||
/// <summary>
|
||||
/// Symbol for HostedSweep creation.
|
||||
/// </summary>
|
||||
private ElementType m_symbol;
|
||||
|
||||
/// <summary>
|
||||
/// Edges which contains references for HostedSweep creation.
|
||||
/// </summary>
|
||||
private List<Edge> m_edgesForHostedSweep = new List<Edge>();
|
||||
|
||||
/// <summary>
|
||||
/// Back up of Symbol.
|
||||
/// </summary>
|
||||
private ElementType m_backUpSymbol;
|
||||
|
||||
/// <summary>
|
||||
/// Back up of Edges.
|
||||
/// </summary>
|
||||
private List<Edge> m_backUpEdges = new List<Edge>();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor.
|
||||
/// </summary>
|
||||
/// <param name="creator">HostedSweepCreator</param>
|
||||
public CreationData(HostedSweepCreator creator)
|
||||
{
|
||||
m_creator = creator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Back up the Symbol and Edges.
|
||||
/// </summary>
|
||||
public void BackUp()
|
||||
{
|
||||
m_backUpSymbol = m_symbol;
|
||||
m_backUpEdges.Clear();
|
||||
m_backUpEdges.AddRange(m_edgesForHostedSweep);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restore the Symbol and Edges.
|
||||
/// </summary>
|
||||
public void Restore()
|
||||
{
|
||||
m_symbol = m_backUpSymbol;
|
||||
m_edgesForHostedSweep.Clear();
|
||||
m_edgesForHostedSweep.AddRange(m_backUpEdges);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If CreationData changed, notify its observers.
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
if (SymbolChanged != null && m_backUpSymbol != null &&
|
||||
m_backUpSymbol.Id.IntegerValue != m_symbol.Id.IntegerValue)
|
||||
SymbolChanged(m_symbol);
|
||||
|
||||
if (EdgeRemoved != null)
|
||||
{
|
||||
foreach (Edge edge in m_backUpEdges)
|
||||
{
|
||||
if (m_edgesForHostedSweep.IndexOf(edge) == -1)
|
||||
{
|
||||
EdgeRemoved(edge);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(EdgeAdded != null)
|
||||
{
|
||||
foreach (Edge edge in m_edgesForHostedSweep)
|
||||
{
|
||||
if (m_backUpEdges.IndexOf(edge) == -1)
|
||||
{
|
||||
EdgeAdded(edge);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creator contains the necessary data to fetch the edges and get the symbol.
|
||||
/// </summary>
|
||||
public HostedSweepCreator Creator
|
||||
{
|
||||
get { return m_creator; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Symbol for HostedSweep creation.
|
||||
/// </summary>
|
||||
public ElementType Symbol
|
||||
{
|
||||
get { return m_symbol; }
|
||||
set { m_symbol = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edges which contains references for HostedSweep creation.
|
||||
/// </summary>
|
||||
public List<Edge> EdgesForHostedSweep
|
||||
{
|
||||
get { return m_edgesForHostedSweep; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,404 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using System.Drawing.Design;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class contains the data for hosted sweep modification.
|
||||
/// </summary>
|
||||
public class ModificationData
|
||||
{
|
||||
/// <summary>
|
||||
/// Element to modify.
|
||||
/// </summary>
|
||||
private HostedSweep m_elemToModify;
|
||||
|
||||
/// <summary>
|
||||
/// Creation data can be modified.
|
||||
/// </summary>
|
||||
private CreationData m_creationData;
|
||||
|
||||
/// <summary>
|
||||
/// Revit active document.
|
||||
/// </summary>
|
||||
private Document m_rvtDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Revit UI document.
|
||||
/// </summary>
|
||||
private UIDocument m_rvtUIDoc;
|
||||
|
||||
/// <summary>
|
||||
/// Sub transaction
|
||||
/// </summary>
|
||||
Transaction m_transaction;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Constructor with HostedSweep and CreationData as parameters.
|
||||
/// </summary>
|
||||
/// <param name="elem">Element to modify</param>
|
||||
/// <param name="creationData">CreationData</param>
|
||||
public ModificationData(HostedSweep elem, CreationData creationData)
|
||||
{
|
||||
m_rvtDoc = creationData.Creator.RvtDocument;
|
||||
m_rvtUIDoc = creationData.Creator.RvtUIDocument;
|
||||
m_elemToModify = elem;
|
||||
m_creationData = creationData;
|
||||
|
||||
m_transaction = new Transaction(m_rvtDoc, "External Tool");
|
||||
|
||||
m_creationData.EdgeAdded +=
|
||||
new CreationData.EdgeEventHandler(m_creationData_EdgeAdded);
|
||||
m_creationData.EdgeRemoved +=
|
||||
new CreationData.EdgeEventHandler(m_creationData_EdgeRemoved);
|
||||
m_creationData.SymbolChanged +=
|
||||
new CreationData.SymbolChangedEventHandler(m_creationData_SymbolChanged);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name of the Creator.
|
||||
/// </summary>
|
||||
public string CreatorName
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_creationData.Creator.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the symbol of the HostedSweep.
|
||||
/// </summary>
|
||||
/// <param name="sym"></param>
|
||||
private void m_creationData_SymbolChanged(ElementType sym)
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
m_elemToModify.ChangeTypeId(sym.Id);
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the edge from the HostedSweep.
|
||||
/// </summary>
|
||||
/// <param name="edge"></param>
|
||||
private void m_creationData_EdgeRemoved(Edge edge)
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
m_elemToModify.RemoveSegment(edge.Reference);
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the edge to the HostedSweep.
|
||||
/// </summary>
|
||||
/// <param name="edge"></param>
|
||||
private void m_creationData_EdgeAdded(Edge edge)
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
if (m_elemToModify is Fascia)
|
||||
{
|
||||
(m_elemToModify as Fascia).AddSegment(edge.Reference);
|
||||
}
|
||||
else if (m_elemToModify is Gutter)
|
||||
{
|
||||
(m_elemToModify as Gutter).AddSegment(edge.Reference);
|
||||
}
|
||||
else if (m_elemToModify is SlabEdge)
|
||||
{
|
||||
(m_elemToModify as SlabEdge).AddSegment(edge.Reference);
|
||||
}
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show the element in a good view.
|
||||
/// </summary>
|
||||
public void ShowElement()
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
m_rvtUIDoc.ShowElements(m_elemToModify);
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Name will be displayed in property grid.
|
||||
/// </summary>
|
||||
[Category("Identity Data")]
|
||||
public String Name
|
||||
{
|
||||
get
|
||||
{
|
||||
String result = "[Id:" + m_elemToModify.Id.IntegerValue + "] ";
|
||||
return result + m_elemToModify.Name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep Angle property.
|
||||
/// </summary>
|
||||
[Category("Profile")]
|
||||
public String Angle
|
||||
{
|
||||
get
|
||||
{
|
||||
Parameter angle = GetParameter("Angle");
|
||||
if (angle != null)
|
||||
return angle.AsValueString();
|
||||
else
|
||||
return m_elemToModify.Angle.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
Parameter angle = GetParameter("Angle");
|
||||
if (angle != null)
|
||||
angle.SetValueString(value);
|
||||
else
|
||||
m_elemToModify.Angle = double.Parse(value);
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep profiles edges, the edges can be removed or added in the
|
||||
/// pop up dialog.
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(CreationDataTypeConverter)),
|
||||
Editor(typeof(EdgeFormUITypeEditor), typeof(UITypeEditor)),
|
||||
Category("Profile"), DisplayName("Profile Edges")]
|
||||
public CreationData AddOrRemoveSegments
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_creationData;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep Length property.
|
||||
/// </summary>
|
||||
[Category("Dimensions")]
|
||||
public string Length
|
||||
{
|
||||
get
|
||||
{
|
||||
Parameter length = GetParameter("Length");
|
||||
if (length != null)
|
||||
return length.AsValueString();
|
||||
else
|
||||
return m_elemToModify.Length.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep HorizontalFlipped property.
|
||||
/// </summary>
|
||||
[Category("Constraints"), DisplayName("Horizontal Profile Flipped")]
|
||||
public bool HorizontalFlipped
|
||||
{
|
||||
get { return m_elemToModify.HorizontalFlipped; }
|
||||
set
|
||||
{
|
||||
if (value != m_elemToModify.HorizontalFlipped)
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
m_elemToModify.HorizontalFlip();
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep HorizontalOffset property.
|
||||
/// </summary>
|
||||
[Category("Constraints"), DisplayName("Horizontal Profile Offset")]
|
||||
public String HorizontalOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
Parameter horiOff = GetParameter("Horizontal Profile Offset");
|
||||
if (horiOff != null)
|
||||
return horiOff.AsValueString();
|
||||
else
|
||||
return m_elemToModify.HorizontalOffset.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
Parameter horiOff = GetParameter("Horizontal Profile Offset");
|
||||
if (horiOff != null)
|
||||
horiOff.SetValueString(value);
|
||||
else
|
||||
m_elemToModify.HorizontalOffset = double.Parse(value);
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep VerticalFlipped property.
|
||||
/// </summary>
|
||||
[Category("Constraints"), DisplayName("Vertical Profile Flipped")]
|
||||
public bool VerticalFlipped
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_elemToModify.VerticalFlipped;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != m_elemToModify.VerticalFlipped)
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
m_elemToModify.VerticalFlip();
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HostedSweep VerticalOffset property.
|
||||
/// </summary>
|
||||
[Category("Constraints"), DisplayName("Vertical Profile Offset")]
|
||||
public String VerticalOffset
|
||||
{
|
||||
get
|
||||
{
|
||||
Parameter vertOff = GetParameter("Vertical Profile Offset");
|
||||
if (vertOff != null)
|
||||
return vertOff.AsValueString();
|
||||
else
|
||||
return m_elemToModify.VerticalOffset.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
StartTransaction();
|
||||
Parameter vertOff = GetParameter("Vertical Profile Offset");
|
||||
if (vertOff != null)
|
||||
vertOff.SetValueString(value);
|
||||
else
|
||||
m_elemToModify.VerticalOffset = double.Parse(value);
|
||||
CommitTransaction();
|
||||
}
|
||||
catch
|
||||
{
|
||||
RollbackTransaction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get parameter by given name.
|
||||
/// </summary>
|
||||
/// <param name="name">name of parameter</param>
|
||||
/// <returns>parameter whose definition name is the given name.</returns>
|
||||
protected Parameter GetParameter(String name)
|
||||
{
|
||||
return m_elemToModify.LookupParameter(name);
|
||||
}
|
||||
|
||||
|
||||
public TransactionStatus StartTransaction()
|
||||
{
|
||||
return m_transaction.Start();
|
||||
}
|
||||
|
||||
public TransactionStatus CommitTransaction()
|
||||
{
|
||||
return m_transaction.Commit();
|
||||
}
|
||||
|
||||
public TransactionStatus RollbackTransaction()
|
||||
{
|
||||
return m_transaction.RollBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is intent to convert CreationData to String.
|
||||
/// </summary>
|
||||
class CreationDataTypeConverter : TypeConverter
|
||||
{
|
||||
/// <summary>
|
||||
/// CreationData can convert to string.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
|
||||
{
|
||||
return destinationType == typeof(String);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Convert CreationData to string.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="culture"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <param name="destinationType"></param>
|
||||
/// <returns></returns>
|
||||
public override object ConvertTo(ITypeDescriptorContext context,
|
||||
System.Globalization.CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
CreationData cd = value as CreationData;
|
||||
if (cd != null)
|
||||
{
|
||||
return "Total " + cd.EdgesForHostedSweep.Count + " Edges";
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
partial class EdgeFetchForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EdgeFetchForm));
|
||||
this.comboBoxTypes = new System.Windows.Forms.ComboBox();
|
||||
this.groupBoxEdges = new System.Windows.Forms.GroupBox();
|
||||
this.treeViewHost = new System.Windows.Forms.TreeView();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||
this.pictureBoxPreview = new System.Windows.Forms.PictureBox();
|
||||
this.label = new System.Windows.Forms.Label();
|
||||
this.imageListForCheckBox = new System.Windows.Forms.ImageList(this.components);
|
||||
this.labelHit = new System.Windows.Forms.Label();
|
||||
this.groupBoxEdges.SuspendLayout();
|
||||
this.groupBox1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// comboBoxTypes
|
||||
//
|
||||
this.comboBoxTypes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxTypes.FormattingEnabled = true;
|
||||
this.comboBoxTypes.Location = new System.Drawing.Point(12, 38);
|
||||
this.comboBoxTypes.Name = "comboBoxTypes";
|
||||
this.comboBoxTypes.Size = new System.Drawing.Size(207, 21);
|
||||
this.comboBoxTypes.TabIndex = 3;
|
||||
//
|
||||
// groupBoxEdges
|
||||
//
|
||||
this.groupBoxEdges.Controls.Add(this.treeViewHost);
|
||||
this.groupBoxEdges.Location = new System.Drawing.Point(12, 65);
|
||||
this.groupBoxEdges.Name = "groupBoxEdges";
|
||||
this.groupBoxEdges.Size = new System.Drawing.Size(207, 610);
|
||||
this.groupBoxEdges.TabIndex = 4;
|
||||
this.groupBoxEdges.TabStop = false;
|
||||
this.groupBoxEdges.Text = "Extract Edges for HostedSweep";
|
||||
//
|
||||
// treeViewHost
|
||||
//
|
||||
this.treeViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.treeViewHost.Location = new System.Drawing.Point(3, 16);
|
||||
this.treeViewHost.Name = "treeViewHost";
|
||||
this.treeViewHost.Size = new System.Drawing.Size(201, 591);
|
||||
this.treeViewHost.TabIndex = 1;
|
||||
this.treeViewHost.BeforeExpand += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeViewHost_BeforeExpand);
|
||||
this.treeViewHost.NodeMouseHover += new System.Windows.Forms.TreeNodeMouseHoverEventHandler(this.treeViewHost_NodeMouseHover);
|
||||
this.treeViewHost.BeforeCollapse += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeViewHost_BeforeCollapse);
|
||||
this.treeViewHost.KeyDown += new System.Windows.Forms.KeyEventHandler(this.treeViewHost_KeyDown);
|
||||
this.treeViewHost.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeViewHost_MouseDown);
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.Location = new System.Drawing.Point(28, 681);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonOK.TabIndex = 5;
|
||||
this.buttonOK.Text = "&OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(125, 681);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 6;
|
||||
this.buttonCancel.Text = "&Cancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// groupBox1
|
||||
//
|
||||
this.groupBox1.Controls.Add(this.pictureBoxPreview);
|
||||
this.groupBox1.Location = new System.Drawing.Point(225, 11);
|
||||
this.groupBox1.Name = "groupBox1";
|
||||
this.groupBox1.Size = new System.Drawing.Size(604, 615);
|
||||
this.groupBox1.TabIndex = 8;
|
||||
this.groupBox1.TabStop = false;
|
||||
this.groupBox1.Text = "Preview";
|
||||
//
|
||||
// pictureBoxPreview
|
||||
//
|
||||
this.pictureBoxPreview.BackColor = System.Drawing.SystemColors.WindowText;
|
||||
this.pictureBoxPreview.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.pictureBoxPreview.Location = new System.Drawing.Point(3, 16);
|
||||
this.pictureBoxPreview.Name = "pictureBoxPreview";
|
||||
this.pictureBoxPreview.Size = new System.Drawing.Size(598, 596);
|
||||
this.pictureBoxPreview.TabIndex = 10;
|
||||
this.pictureBoxPreview.TabStop = false;
|
||||
this.pictureBoxPreview.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPreview_MouseDown);
|
||||
this.pictureBoxPreview.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPreview_MouseMove);
|
||||
this.pictureBoxPreview.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxPreview_Paint);
|
||||
this.pictureBoxPreview.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPreview_MouseClick);
|
||||
//
|
||||
// label
|
||||
//
|
||||
this.label.AutoSize = true;
|
||||
this.label.Location = new System.Drawing.Point(15, 11);
|
||||
this.label.Name = "label";
|
||||
this.label.Size = new System.Drawing.Size(157, 13);
|
||||
this.label.TabIndex = 9;
|
||||
this.label.Text = "Select a type for HostedSweep:";
|
||||
//
|
||||
// imageListForCheckBox
|
||||
//
|
||||
this.imageListForCheckBox.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListForCheckBox.ImageStream")));
|
||||
this.imageListForCheckBox.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageListForCheckBox.Images.SetKeyName(0, "CBUnchecked.bmp");
|
||||
this.imageListForCheckBox.Images.SetKeyName(1, "CBchecked.bmp");
|
||||
this.imageListForCheckBox.Images.SetKeyName(2, "CBIndeterminate.bmp");
|
||||
//
|
||||
// labelHit
|
||||
//
|
||||
this.labelHit.AutoSize = true;
|
||||
this.labelHit.Location = new System.Drawing.Point(226, 633);
|
||||
this.labelHit.Name = "labelHit";
|
||||
this.labelHit.Size = new System.Drawing.Size(527, 52);
|
||||
this.labelHit.TabIndex = 10;
|
||||
this.labelHit.Text = resources.GetString("labelHit.Text");
|
||||
//
|
||||
// EdgeFetchForm
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonCancel;
|
||||
this.ClientSize = new System.Drawing.Size(834, 716);
|
||||
this.Controls.Add(this.labelHit);
|
||||
this.Controls.Add(this.label);
|
||||
this.Controls.Add(this.groupBox1);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.Controls.Add(this.groupBoxEdges);
|
||||
this.Controls.Add(this.comboBoxTypes);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "EdgeFetchForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Extract edges for Hosted Sweep";
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.EdgeFetch_KeyDown);
|
||||
this.Load += new System.EventHandler(this.EdgeFetch_Load);
|
||||
this.groupBoxEdges.ResumeLayout(false);
|
||||
this.groupBox1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ComboBox comboBoxTypes;
|
||||
private System.Windows.Forms.GroupBox groupBoxEdges;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.Button buttonCancel;
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.TreeView treeViewHost;
|
||||
private System.Windows.Forms.Label label;
|
||||
private System.Windows.Forms.ImageList imageListForCheckBox;
|
||||
private System.Windows.Forms.PictureBox pictureBoxPreview;
|
||||
private System.Windows.Forms.Label labelHit;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,644 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This form is intent to fetch edges for hosted sweep creation or modification.
|
||||
/// It contains a picture box for geometry preview and a tree view to list all the edges
|
||||
/// which hosted sweep can be created on.
|
||||
/// If the user mouse-over an edge where a hosted sweep can be created, the edge will be
|
||||
/// highlighted in yellow. If user clicks on the highlighted edge, the edge will
|
||||
/// be marked as selected in red color. Click it again to un-select, the color will turn back.
|
||||
/// Edge selection from preview box will be reflected in edge list and vice versa.
|
||||
/// The geometry displayed in the picture box can be rotated with left mouse or
|
||||
/// arrow keys (up, down, left and right) and zoomed with right mouse.
|
||||
/// </summary>
|
||||
public partial class EdgeFetchForm : System.Windows.Forms.Form
|
||||
{
|
||||
#region Fields and Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Contains all the data need to fetch edges.
|
||||
/// </summary>
|
||||
private CreationData m_creationData;
|
||||
|
||||
/// <summary>
|
||||
/// Flag to indicate whether or not we should cancel expand or collapse
|
||||
/// the tree-node which contains children.
|
||||
/// </summary>
|
||||
private bool m_cancelExpandOrCollapse;
|
||||
|
||||
/// <summary>
|
||||
/// Active element displayed in the preview.
|
||||
/// </summary>
|
||||
private Autodesk.Revit.DB.Element m_activeElem;
|
||||
|
||||
/// <summary>
|
||||
/// Yield rotation and scale transformation for current geometry display.
|
||||
/// </summary>
|
||||
private TrackBall m_trackBall;
|
||||
|
||||
/// <summary>
|
||||
/// Move the Graphics origin to preview center and flip its y-Axis.
|
||||
/// </summary>
|
||||
private Matrix m_centerMatrix;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public EdgeFetchForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customize constructor.
|
||||
/// </summary>
|
||||
/// <param name="creationData"></param>
|
||||
public EdgeFetchForm(CreationData creationData)
|
||||
: this()
|
||||
{
|
||||
m_creationData = creationData;
|
||||
treeViewHost.StateImageList = imageListForCheckBox;
|
||||
m_trackBall = new TrackBall();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Initialize Methods
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the combo box data source with Autodesk.Revit.DB.
|
||||
/// e.g. FasciaTypes, GutterTypes, SlabEdgeTypes, and so on.
|
||||
/// </summary>
|
||||
private void InitializeTypes()
|
||||
{
|
||||
List<object> objects = new List<object>();
|
||||
object selected = null;
|
||||
foreach (object obj in m_creationData.Creator.AllTypes)
|
||||
{
|
||||
objects.Add(obj);
|
||||
if (m_creationData.Symbol != null)
|
||||
{
|
||||
if ((obj as Autodesk.Revit.DB.ElementType).Id.IntegerValue == m_creationData.Symbol.Id.IntegerValue)
|
||||
{
|
||||
selected = obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
comboBoxTypes.DataSource = objects;
|
||||
comboBoxTypes.DisplayMember = "Name";
|
||||
|
||||
if (selected != null)
|
||||
comboBoxTypes.SelectedItem = selected;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the TreeView: create a tree according to geometry edges
|
||||
/// and set each node's check status to unchecked.
|
||||
/// </summary>
|
||||
private void InitializeTree()
|
||||
{
|
||||
HostedSweepCreator creator = m_creationData.Creator;
|
||||
|
||||
TreeNode rootNode = new TreeNode();
|
||||
rootNode.StateImageIndex = (int)CheckState.Unchecked;
|
||||
foreach (KeyValuePair<Autodesk.Revit.DB.Element, List<Edge>> pair in creator.SupportEdges)
|
||||
{
|
||||
Autodesk.Revit.DB.Element elem = pair.Key;
|
||||
TreeNode elemNode = new TreeNode("[Id:" + elem.Id.IntegerValue + "] " + elem.Name);
|
||||
elemNode.StateImageIndex = (int)CheckState.Unchecked;
|
||||
rootNode.Nodes.Add(elemNode);
|
||||
elemNode.Tag = elem;
|
||||
int i = 1;
|
||||
foreach (Edge edge in pair.Value)
|
||||
{
|
||||
TreeNode edgeNode = new TreeNode("Edge " + i);
|
||||
edgeNode.StateImageIndex = (int)CheckState.Unchecked;
|
||||
edgeNode.Tag = edge;
|
||||
elemNode.Nodes.Add(edgeNode);
|
||||
++i;
|
||||
}
|
||||
}
|
||||
rootNode.Text = "Roofs";
|
||||
if (creator is SlabEdgeCreator)
|
||||
{
|
||||
rootNode.Text = "Floors";
|
||||
}
|
||||
treeViewHost.Nodes.Add(rootNode);
|
||||
treeViewHost.TopNode.Expand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize element geometry.
|
||||
/// </summary>
|
||||
private void InitializeElementGeometry()
|
||||
{
|
||||
foreach (ElementGeometry elemGeom in m_creationData.Creator.ElemGeomDic.Values)
|
||||
{
|
||||
elemGeom.InitializeTransform(pictureBoxPreview.Width * 0.8, pictureBoxPreview.Height * 0.8);
|
||||
elemGeom.ResetEdgeStates();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize tree check states according to edges which hosted sweep can be created on.
|
||||
/// </summary>
|
||||
private void InitializeTreeCheckStates()
|
||||
{
|
||||
if (m_creationData.EdgesForHostedSweep.Count == 0) return;
|
||||
|
||||
// Initialize edge binding selection state
|
||||
foreach(Edge edge in m_creationData.EdgesForHostedSweep)
|
||||
{
|
||||
foreach(ElementGeometry elemGeom in m_creationData.Creator.ElemGeomDic.Values)
|
||||
{
|
||||
if(elemGeom.EdgeBindingDic.ContainsKey(edge))
|
||||
{
|
||||
elemGeom.EdgeBindingDic[edge].IsSelected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize tree node selection state
|
||||
// check on all the edges on which we created hostd sweeps
|
||||
TreeNode root = treeViewHost.Nodes[0];
|
||||
foreach(TreeNode elemNode in root.Nodes)
|
||||
{
|
||||
foreach(TreeNode edgeNode in elemNode.Nodes)
|
||||
{
|
||||
Edge edge = edgeNode.Tag as Edge;
|
||||
if(m_creationData.EdgesForHostedSweep.IndexOf(edge) != -1)
|
||||
{
|
||||
edgeNode.StateImageIndex = (int)CheckState.Checked;
|
||||
UpdateParent(edgeNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize text properties of this form.
|
||||
/// </summary>
|
||||
private void InitializeText()
|
||||
{
|
||||
this.Text = "Pick edges for " + m_creationData.Creator.Name;
|
||||
this.label.Text = "Select a type for " + m_creationData.Creator.Name;
|
||||
this.groupBoxEdges.Text = "All edges for " + m_creationData.Creator.Name;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize something related to the geometry preview.
|
||||
/// </summary>
|
||||
private void InitializePreview()
|
||||
{
|
||||
m_centerMatrix = new Matrix(1, 0, 0, -1,
|
||||
(float)pictureBoxPreview.Width / 2.0f, (float)pictureBoxPreview.Height / 2.0f);
|
||||
this.KeyPreview = true;
|
||||
|
||||
foreach (Autodesk.Revit.DB.Element elem in m_creationData.Creator.ElemGeomDic.Keys)
|
||||
{
|
||||
m_activeElem = elem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Auxiliary Methods
|
||||
|
||||
/// <summary>
|
||||
/// Extract the checked edges in the whole tree to CreationData.EdgesForHostedSweep.
|
||||
/// </summary>
|
||||
private void ExtractCheckedEdgesAndSelectedSymbol()
|
||||
{
|
||||
m_creationData.EdgesForHostedSweep.Clear();
|
||||
TreeNode rootNode = treeViewHost.Nodes[0];
|
||||
foreach (TreeNode hostNode in rootNode.Nodes)
|
||||
{
|
||||
foreach (TreeNode edgeNode in hostNode.Nodes)
|
||||
{
|
||||
|
||||
if (edgeNode.StateImageIndex == (int)CheckState.Checked)
|
||||
m_creationData.EdgesForHostedSweep.Add(edgeNode.Tag as Edge);
|
||||
}
|
||||
}
|
||||
m_creationData.Symbol = comboBoxTypes.SelectedItem as Autodesk.Revit.DB.ElementType;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update tree node check status, it will impact its children and parents' status.
|
||||
/// </summary>
|
||||
/// <param name="node">Tree node to update</param>
|
||||
/// <param name="state">CheckState value</param>
|
||||
private void UpdateNodeCheckStatus(TreeNode node, CheckState state)
|
||||
{
|
||||
node.StateImageIndex = (int)state;
|
||||
if(node.Tag != null && node.Tag is Edge && m_activeElem != null)
|
||||
{
|
||||
Edge edge = node.Tag as Edge;
|
||||
Autodesk.Revit.DB.Element elem = node.Parent.Tag as Autodesk.Revit.DB.Element;
|
||||
ElementGeometry elemGeom = m_creationData.Creator.ElemGeomDic[elem];
|
||||
elemGeom.EdgeBindingDic[edge].IsSelected =
|
||||
(node.StateImageIndex == (int)CheckState.Checked);
|
||||
}
|
||||
UpdateChildren(node);
|
||||
UpdateParent(node);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursively update tree children's status to match its parent status.
|
||||
/// </summary>
|
||||
/// <param name="node">Parent node whose children will be updated</param>
|
||||
private void UpdateChildren(TreeNode node)
|
||||
{
|
||||
foreach (TreeNode child in node.Nodes)
|
||||
{
|
||||
if (child.StateImageIndex != node.StateImageIndex)
|
||||
{
|
||||
child.StateImageIndex = node.StateImageIndex;
|
||||
|
||||
if(m_activeElem != null && child.Tag != null && child.Tag is Edge)
|
||||
{
|
||||
Edge edge = child.Tag as Edge;
|
||||
Autodesk.Revit.DB.Element elem = child.Parent.Tag as Autodesk.Revit.DB.Element;
|
||||
ElementGeometry elemGeom = m_creationData.Creator.ElemGeomDic[elem];
|
||||
elemGeom.EdgeBindingDic[edge].IsSelected =
|
||||
(child.StateImageIndex == (int)CheckState.Checked);
|
||||
}
|
||||
}
|
||||
UpdateChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recursively update tree parent's status to match its children status.
|
||||
/// </summary>
|
||||
/// <param name="node">Child whose parents will be updated</param>
|
||||
private void UpdateParent(TreeNode node)
|
||||
{
|
||||
TreeNode parent = node.Parent;
|
||||
if (parent == null) return;
|
||||
foreach (TreeNode brother in parent.Nodes)
|
||||
{
|
||||
if (brother.StateImageIndex != node.StateImageIndex)
|
||||
{
|
||||
parent.StateImageIndex = (int)CheckState.Indeterminate;
|
||||
UpdateParent(parent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
parent.StateImageIndex = node.StateImageIndex;
|
||||
UpdateParent(parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Switch geometry displayed in the preview according to the tree node.
|
||||
/// </summary>
|
||||
/// <param name="node">Tree node to active</param>
|
||||
private void ActiveNode(TreeNode node)
|
||||
{
|
||||
if (node.Tag == null) return;
|
||||
|
||||
if (node.Tag is Autodesk.Revit.DB.Element)
|
||||
m_activeElem = node.Tag as Autodesk.Revit.DB.Element;
|
||||
else if (node.Tag is Edge)
|
||||
{
|
||||
m_activeElem = node.Parent.Tag as Autodesk.Revit.DB.Element;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear Highlighted status of all highlighted edges.
|
||||
/// </summary>
|
||||
private void ClearAllHighLight()
|
||||
{
|
||||
if (m_activeElem == null) return;
|
||||
ElementGeometry elemGeom = m_creationData.Creator.ElemGeomDic[m_activeElem];
|
||||
|
||||
foreach (Edge edge in m_creationData.Creator.SupportEdges[m_activeElem])
|
||||
{
|
||||
elemGeom.EdgeBindingDic[edge].IsHighLighted = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the related tree node of an edit
|
||||
/// </summary>
|
||||
/// <param name="edge">Given edge to find its tree-node</param>
|
||||
/// <returns>Tree-node matched with the given edge</returns>
|
||||
private TreeNode GetEdgeTreeNode(Edge edge)
|
||||
{
|
||||
TreeNode result = null;
|
||||
TreeNode root = treeViewHost.Nodes[0];
|
||||
Stack<TreeNode> todo = new Stack<TreeNode>();
|
||||
todo.Push(root);
|
||||
while (todo.Count > 0)
|
||||
{
|
||||
TreeNode node = todo.Pop();
|
||||
if (node.Tag != null && node.Tag is Edge && (node.Tag as Edge) == edge)
|
||||
{
|
||||
result = node;
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (TreeNode tmpNode in node.Nodes)
|
||||
{
|
||||
todo.Push(tmpNode);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event handles
|
||||
|
||||
/// <summary>
|
||||
/// Extract checked edges and verify there are edges
|
||||
/// checked in the treeView, if there aren't edges to be checked, complain
|
||||
/// about it with a message box, otherwise close this from.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
ExtractCheckedEdgesAndSelectedSymbol();
|
||||
if (m_creationData.EdgesForHostedSweep.Count == 0)
|
||||
{
|
||||
TaskDialog.Show("Revit", "At least one edge should be selected!");
|
||||
return;
|
||||
}
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This form Load event handle, all the initializations will be in here.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void EdgeFetch_Load(object sender, EventArgs e)
|
||||
{
|
||||
InitializeTypes();
|
||||
InitializeTree();
|
||||
InitializeElementGeometry();
|
||||
InitializeTreeCheckStates();
|
||||
InitializeText();
|
||||
InitializePreview();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Suppress the default behaviors that double-click
|
||||
/// on a tree-node which contains children will make the tree-node collapse or expand.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void treeViewHost_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
if (m_cancelExpandOrCollapse)
|
||||
e.Cancel = true;
|
||||
m_cancelExpandOrCollapse = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Suppress the default behaviors that double-click
|
||||
/// on a tree-node which contains children will make the tree-node collapse or expand.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void treeViewHost_BeforeExpand(object sender, TreeViewCancelEventArgs e)
|
||||
{
|
||||
if (m_cancelExpandOrCollapse)
|
||||
e.Cancel = true;
|
||||
m_cancelExpandOrCollapse = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw the geometry.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void pictureBoxPreview_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
if (m_activeElem == null) return;
|
||||
|
||||
ElementGeometry elemGeo = null;
|
||||
if (!m_creationData.Creator.ElemGeomDic.TryGetValue(m_activeElem, out elemGeo)) return;
|
||||
|
||||
e.Graphics.Transform = m_centerMatrix;
|
||||
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
||||
elemGeo.Draw(e.Graphics);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the track ball.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void pictureBoxPreview_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
m_trackBall.OnMouseDown(pictureBoxPreview.Width, pictureBoxPreview.Height, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotate or zoom the displayed geometry, or highlight the edge under the mouse location.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void pictureBoxPreview_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (m_activeElem == null) return;
|
||||
|
||||
m_trackBall.OnMouseMove(e);
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
m_creationData.Creator.ElemGeomDic[m_activeElem].Rotation *= m_trackBall.Rotation;
|
||||
pictureBoxPreview.Refresh();
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
m_creationData.Creator.ElemGeomDic[m_activeElem].Scale *= m_trackBall.Scale;
|
||||
pictureBoxPreview.Refresh();
|
||||
}
|
||||
|
||||
if (e.Button == MouseButtons.None)
|
||||
{
|
||||
ClearAllHighLight();
|
||||
pictureBoxPreview.Refresh();
|
||||
Matrix mat = (Matrix)m_centerMatrix.Clone();
|
||||
mat.Invert();
|
||||
PointF[] pts = new PointF[1] { e.Location };
|
||||
mat.TransformPoints(pts);
|
||||
ElementGeometry elemGeom = m_creationData.Creator.ElemGeomDic[m_activeElem];
|
||||
foreach (Edge edge in m_creationData.Creator.SupportEdges[m_activeElem])
|
||||
{
|
||||
if (elemGeom.EdgeBindingDic.ContainsKey(edge))
|
||||
{
|
||||
if (elemGeom.EdgeBindingDic[edge].HighLight(pts[0].X, pts[0].Y))
|
||||
{
|
||||
pictureBoxPreview.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select or unselect edge
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void pictureBoxPreview_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (m_activeElem == null || e.Button != MouseButtons.Left) return;
|
||||
|
||||
ElementGeometry elemGeom = m_creationData.Creator.ElemGeomDic[m_activeElem];
|
||||
foreach (Edge edge in m_creationData.Creator.SupportEdges[m_activeElem])
|
||||
{
|
||||
if (elemGeom.EdgeBindingDic.ContainsKey(edge))
|
||||
{
|
||||
if (elemGeom.EdgeBindingDic[edge].IsHighLighted)
|
||||
{
|
||||
bool isSelect = elemGeom.EdgeBindingDic[edge].IsSelected;
|
||||
elemGeom.EdgeBindingDic[edge].IsHighLighted = false;
|
||||
elemGeom.EdgeBindingDic[edge].IsSelected = !isSelect;
|
||||
|
||||
TreeNode node = GetEdgeTreeNode(edge);
|
||||
|
||||
CheckState state = isSelect ? CheckState.Unchecked : CheckState.Checked;
|
||||
UpdateNodeCheckStatus(node, state);
|
||||
pictureBoxPreview.Refresh();
|
||||
treeViewHost.Refresh();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Highlight the edge in the preview
|
||||
/// if mouse-over an edge tree-node.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void treeViewHost_NodeMouseHover(object sender, TreeNodeMouseHoverEventArgs e)
|
||||
{
|
||||
TreeNode node = e.Node;
|
||||
treeViewHost.SelectedNode = e.Node;
|
||||
ClearAllHighLight();
|
||||
ActiveNode(node);
|
||||
pictureBoxPreview.Refresh();
|
||||
if (m_activeElem == null || node.Tag == null || !(node.Tag is Edge)) return;
|
||||
|
||||
ElementGeometry elemGeom = m_creationData.Creator.ElemGeomDic[m_activeElem];
|
||||
elemGeom.EdgeBindingDic[node.Tag as Edge].IsHighLighted = true;
|
||||
pictureBoxPreview.Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use arrow keys to rotate the display of geometry.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void EdgeFetch_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
m_trackBall.OnKeyDown(e);
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Up:
|
||||
case Keys.Down:
|
||||
case Keys.Left:
|
||||
case Keys.Right:
|
||||
m_creationData.Creator.ElemGeomDic[m_activeElem].Rotation *= m_trackBall.Rotation;
|
||||
pictureBoxPreview.Refresh();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Suppress the key input.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void treeViewHost_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Select or un-select the key-node
|
||||
/// if down the left mouse button in the area of check-box or label.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void treeViewHost_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
TreeViewHitTestInfo hitInfo = treeViewHost.HitTest(e.Location);
|
||||
|
||||
if(e.Button == MouseButtons.Left &&
|
||||
(hitInfo.Location == TreeViewHitTestLocations.StateImage ||
|
||||
hitInfo.Location == TreeViewHitTestLocations.Label))
|
||||
{
|
||||
// mouse down in area of state image or label.
|
||||
TreeNode node = hitInfo.Node;
|
||||
if(node.Nodes.Count > 0)
|
||||
// cancel the expand or collapse of node which has children.
|
||||
m_cancelExpandOrCollapse = true;
|
||||
|
||||
// active the node.
|
||||
ActiveNode(node);
|
||||
|
||||
// select or un-select the node.
|
||||
CheckState checkState = (CheckState)((node.StateImageIndex + 1) % 2);
|
||||
UpdateNodeCheckStatus(node, checkState);
|
||||
|
||||
pictureBoxPreview.Refresh();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="imageListForCheckBox.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="imageListForCheckBox.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADA
|
||||
CQAAAk1TRnQBSQFMAgEBAwEAAQQBAAEEAQABEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
|
||||
AwABQAMAARADAAEBAQABCAYAAQQYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
|
||||
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
|
||||
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
|
||||
AWYDAAGZAwABzAIAATMDAAIzAgABMwFmAgABMwGZAgABMwHMAgABMwH/AgABZgMAAWYBMwIAAmYCAAFm
|
||||
AZkCAAFmAcwCAAFmAf8CAAGZAwABmQEzAgABmQFmAgACmQIAAZkBzAIAAZkB/wIAAcwDAAHMATMCAAHM
|
||||
AWYCAAHMAZkCAALMAgABzAH/AgAB/wFmAgAB/wGZAgAB/wHMAQABMwH/AgAB/wEAATMBAAEzAQABZgEA
|
||||
ATMBAAGZAQABMwEAAcwBAAEzAQAB/wEAAf8BMwIAAzMBAAIzAWYBAAIzAZkBAAIzAcwBAAIzAf8BAAEz
|
||||
AWYCAAEzAWYBMwEAATMCZgEAATMBZgGZAQABMwFmAcwBAAEzAWYB/wEAATMBmQIAATMBmQEzAQABMwGZ
|
||||
AWYBAAEzApkBAAEzAZkBzAEAATMBmQH/AQABMwHMAgABMwHMATMBAAEzAcwBZgEAATMBzAGZAQABMwLM
|
||||
AQABMwHMAf8BAAEzAf8BMwEAATMB/wFmAQABMwH/AZkBAAEzAf8BzAEAATMC/wEAAWYDAAFmAQABMwEA
|
||||
AWYBAAFmAQABZgEAAZkBAAFmAQABzAEAAWYBAAH/AQABZgEzAgABZgIzAQABZgEzAWYBAAFmATMBmQEA
|
||||
AWYBMwHMAQABZgEzAf8BAAJmAgACZgEzAQADZgEAAmYBmQEAAmYBzAEAAWYBmQIAAWYBmQEzAQABZgGZ
|
||||
AWYBAAFmApkBAAFmAZkBzAEAAWYBmQH/AQABZgHMAgABZgHMATMBAAFmAcwBmQEAAWYCzAEAAWYBzAH/
|
||||
AQABZgH/AgABZgH/ATMBAAFmAf8BmQEAAWYB/wHMAQABzAEAAf8BAAH/AQABzAEAApkCAAGZATMBmQEA
|
||||
AZkBAAGZAQABmQEAAcwBAAGZAwABmQIzAQABmQEAAWYBAAGZATMBzAEAAZkBAAH/AQABmQFmAgABmQFm
|
||||
ATMBAAGZATMBZgEAAZkBZgGZAQABmQFmAcwBAAGZATMB/wEAApkBMwEAApkBZgEAA5kBAAKZAcwBAAKZ
|
||||
Af8BAAGZAcwCAAGZAcwBMwEAAWYBzAFmAQABmQHMAZkBAAGZAswBAAGZAcwB/wEAAZkB/wIAAZkB/wEz
|
||||
AQABmQHMAWYBAAGZAf8BmQEAAZkB/wHMAQABmQL/AQABzAMAAZkBAAEzAQABzAEAAWYBAAHMAQABmQEA
|
||||
AcwBAAHMAQABmQEzAgABzAIzAQABzAEzAWYBAAHMATMBmQEAAcwBMwHMAQABzAEzAf8BAAHMAWYCAAHM
|
||||
AWYBMwEAAZkCZgEAAcwBZgGZAQABzAFmAcwBAAGZAWYB/wEAAcwBmQIAAcwBmQEzAQABzAGZAWYBAAHM
|
||||
ApkBAAHMAZkBzAEAAcwBmQH/AQACzAIAAswBMwEAAswBZgEAAswBmQEAA8wBAALMAf8BAAHMAf8CAAHM
|
||||
Af8BMwEAAZkB/wFmAQABzAH/AZkBAAHMAf8BzAEAAcwC/wEAAcwBAAEzAQAB/wEAAWYBAAH/AQABmQEA
|
||||
AcwBMwIAAf8CMwEAAf8BMwFmAQAB/wEzAZkBAAH/ATMBzAEAAf8BMwH/AQAB/wFmAgAB/wFmATMBAAHM
|
||||
AmYBAAH/AWYBmQEAAf8BZgHMAQABzAFmAf8BAAH/AZkCAAH/AZkBMwEAAf8BmQFmAQAB/wKZAQAB/wGZ
|
||||
AcwBAAH/AZkB/wEAAf8BzAIAAf8BzAEzAQAB/wHMAWYBAAH/AcwBmQEAAf8CzAEAAf8BzAH/AQAC/wEz
|
||||
AQABzAH/AWYBAAL/AZkBAAL/AcwBAAJmAf8BAAFmAf8BZgEAAWYC/wEAAf8CZgEAAf8BZgH/AQAC/wFm
|
||||
AQABIQEAAaUBAANfAQADdwEAA4YBAAOWAQADywEAA7IBAAPXAQAD3QEAA+MBAAPqAQAD8QEAA/gBAAHw
|
||||
AfsB/wEAAaQCoAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8BAAL/AgAD/wEAMBsQAAIbDLwEGwy8
|
||||
BBsMvAIbEAABGwHxDIsBvAIbAfEMiwG8AhsB8QyLAbwBGxAAARsB8QGLA/QB9gb/AYsBvAIbAfEBiwL0
|
||||
AfYH/wGLAbwCGwHxAYsC9AH2B/8BiwG8ARsQAAEbAfEBiwHzBPQF/wGLAbwCGwHxAYsD9AHyAfEF/wGL
|
||||
AbwCGwHxAYsB9AHzAggBwgPxAv8BiwG8ARsQAAEbAfEBiwLzBPQE/wGLAbwCGwHxAYsB8wH0AfIClwHx
|
||||
BP8BiwG8AhsB8QGLAfMB8AaXAfEB/wGLAbwBGxAAARsB8QGLA/ME9AP/AYsBvAIbAfEBiwHzAfEBlwJP
|
||||
AZcBwgP/AYsBvAIbAfEBiwHzAQgGlwHxAf8BiwG8ARsQAAEbAfEBiwHyA/ME9AL/AYsBvAIbAfEBiwHz
|
||||
AQgBTwFVAZcBTwGXAfEC/wGLAbwCGwHxAYsB8wEIBpcB8QH/AYsBvAEbEAABGwHxAYsD8gLzBPQB/wGL
|
||||
AbwCGwHxAYsB8gEIAU8CCAGXAU8BlwHxAf8BiwG8AhsB8QGLAfIBCAaXAcIB/wGLAbwBGxAAARsB8QGL
|
||||
AfEC8gPzA/QB9gGLAbwCGwHxAYsB8gHwAQgC8wEIAZcBTwEIAf8BiwG8AhsB8QGLAfIBCAaXAQgB/wGL
|
||||
AbwBGxAAARsB8QGLAfEE8gLzA/QBiwG8AhsB8QGLA/ID8wEIAZcBCAH2AYsBvAIbAfEBiwHyAQgGlwEI
|
||||
AfYBiwG8ARsQAAEbAfEBiwHwAfED8gPzAvQBiwG8AhsB8QGLBPID8wHwAfMB9AGLAbwCGwHxAYsB8gHx
|
||||
BQgB8AHzAfQBiwG8ARsQAAEbAfEBiwLwAvEC8gPzAfQBiwG8AhsB8QGLBfID8wL0AYsBvAIbAfEBiwXy
|
||||
A/MC9AGLAbwBGxAAARsB8QyLAbwCGwHxDIsBvAIbAfEMiwG8ARsQAAIbDPEEGwzxBBsM8QIbEAAwGxAA
|
||||
AUIBTQE+BwABPgMAASgDAAFAAwABEAMAAQEBAAEBBQABgBcAA/+BAAs=
|
||||
</value>
|
||||
</data>
|
||||
<data name="labelHit.Text" xml:space="preserve">
|
||||
<value>Mouse-over an edge where a hosted sweep can be created, the edge will be highlighted in yellow.
|
||||
Click on the highlighted edge to select it, or click again to un-select.
|
||||
Rotate the geometry by holding the left mouse button and turning, or zoom by holding the right button to move.
|
||||
Pressing arrow keys will also rotate the geometry. </value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing.Design;
|
||||
using System.Windows.Forms.Design;
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is intent to provide a model dialog in property grid control.
|
||||
/// </summary>
|
||||
class EdgeFormUITypeEditor : UITypeEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Return the Modal style.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <returns></returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(
|
||||
System.ComponentModel.ITypeDescriptorContext context)
|
||||
{
|
||||
return UITypeEditorEditStyle.Modal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a form to add or remove edges from hosted sweep, and also can change the
|
||||
/// type of hosted sweep.
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="provider"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
public override object EditValue(System.ComponentModel.ITypeDescriptorContext context,
|
||||
IServiceProvider provider, object value)
|
||||
{
|
||||
IWindowsFormsEditorService winSrv = (IWindowsFormsEditorService)provider.
|
||||
GetService(typeof(IWindowsFormsEditorService));
|
||||
|
||||
CreationData creationData = value as CreationData;
|
||||
creationData.BackUp();
|
||||
using (EdgeFetchForm form = new EdgeFetchForm(creationData))
|
||||
{
|
||||
if (winSrv.ShowDialog(form) == System.Windows.Forms.DialogResult.OK)
|
||||
creationData.Update();
|
||||
else
|
||||
creationData.Restore();
|
||||
}
|
||||
return creationData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
partial class HostedSweepModifyForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HostedSweepModifyForm));
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
|
||||
this.propertyGrid = new System.Windows.Forms.PropertyGrid();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonOK.Location = new System.Drawing.Point(110, 451);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonOK.TabIndex = 2;
|
||||
this.buttonOK.Text = "&OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// imageList1
|
||||
//
|
||||
this.imageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
|
||||
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
|
||||
this.imageList1.Images.SetKeyName(0, "icon_zoomOut.gif");
|
||||
this.imageList1.Images.SetKeyName(1, "icon_zoomIn.gif");
|
||||
this.imageList1.Images.SetKeyName(2, "nav_band_contract.gif");
|
||||
this.imageList1.Images.SetKeyName(3, "nav_band_expand.gif");
|
||||
//
|
||||
// propertyGrid
|
||||
//
|
||||
this.propertyGrid.Location = new System.Drawing.Point(10, 12);
|
||||
this.propertyGrid.Name = "propertyGrid";
|
||||
this.propertyGrid.Size = new System.Drawing.Size(295, 433);
|
||||
this.propertyGrid.TabIndex = 4;
|
||||
//
|
||||
// HostedSweepModify
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonOK;
|
||||
this.ClientSize = new System.Drawing.Size(315, 486);
|
||||
this.Controls.Add(this.propertyGrid);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "HostedSweepModify";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Modify Hosted Sweep";
|
||||
this.Load += new System.EventHandler(this.HostedSweepModify_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.ImageList imageList1;
|
||||
private System.Windows.Forms.PropertyGrid propertyGrid;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Autodesk.Revit;
|
||||
using Autodesk.Revit.DB;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This form contains a property grid control to modify the property of hosted sweep.
|
||||
/// </summary>
|
||||
public partial class HostedSweepModifyForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Data for modification.
|
||||
/// </summary>
|
||||
private ModificationData m_modificationData;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor.
|
||||
/// </summary>
|
||||
public HostedSweepModifyForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customize constructor contains a parameter ModificationData.
|
||||
/// </summary>
|
||||
/// <param name="modificationData"></param>
|
||||
public HostedSweepModifyForm(ModificationData modificationData)
|
||||
: this()
|
||||
{
|
||||
m_modificationData = modificationData;
|
||||
this.Text = "Modify " + m_modificationData.CreatorName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OK button, exit this form with DialogResult.OK.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load event, set the data source for property-grid.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void HostedSweepModify_Load(object sender, EventArgs e)
|
||||
{
|
||||
propertyGrid.SelectedObject = m_modificationData;
|
||||
m_modificationData.ShowElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>
|
||||
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w
|
||||
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
|
||||
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAABo
|
||||
DwAAAk1TRnQBSQFMAgEBBAEAAQkBAAEEAQABEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA
|
||||
AwABIAMAAQEBAAEgBgABIP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8AtgABKwIBAUABKwIB
|
||||
AUABKwIBAUABKwIBAUABKwIBAUABKwIBAUABKwIBAUAkAAErAgEBQAErAgEBQAErAgEBQAErAgEBQAEr
|
||||
AgEBQAErAgEBQAErAgEBQEAAAUgCAgGAAUgCAgGAASsCAQFANAABSAICAYABSAICAYABKwIBAUAUAAFI
|
||||
AgIBgAP+Af8D9wH/A/MB/wPzAf8D8wH/A/UB/wP9Af8BSAICAYAcAAFIAgIBgAP+Af8D9wH/A/MB/wPz
|
||||
Af8D8wH/A/UB/wP9Af8BSAICAYA4AAFOAgIBjwFbAXQBgQH/AUIBawGEAf8BSAICAYAwAAFOAgIBjwFb
|
||||
AXQBgQH/AUIBawGEAf8BSAICAYAQAAFOAgIBjwP9Af8D8gH/A+oB/wPnAf8D5gH/A+cB/wPpAf8D7AH/
|
||||
A/0B/wFOAgIBjxQAAU4CAgGPA/0B/wPyAf8D6gH/A+cB/wPmAf8D5wH/A+kB/wPsAf8D/QH/AU4CAgGP
|
||||
MAABSAICAYABWwF0AYEB/wEzAVgBegH/AYEBqgHcAf8BSAICAYAsAAFIAgIBgAFbAXQBgQH/ATMBWAF6
|
||||
Af8BgQGqAdwB/wFIAgIBgAwAAUgCAgGAA/cB/wPvAf8D5gH/A+YB/wPmAf8D5gH/A+YB/wPmAf8D5gH/
|
||||
A+YB/wP9Af8BSAICAYAMAAFIAgIBgAP3Af8D7wH/A+YB/wPmAf8D5gH/A+YB/wPmAf8D5gH/A+YB/wPm
|
||||
Af8D/QH/AUgCAgGAEAABIgIBATABiQGEAYEB/wF8AXUBbwH/AXwBcgFqAf8BfgF2AW8B/wGBAX8BeQH/
|
||||
AUECAQFwAXkBgQGEAf8BRQFtAYUB/wGBAaoB3AH/AU4CAgGPFAABIgIBATABiQGEAYEB/wF8AXUBbwH/
|
||||
AXwBcgFqAf8BfgF2AW8B/wGBAX8BeQH/AUECAQFwAXkBgQGEAf8BRQFtAYUB/wGBAaoB3AH/AU4CAgGP
|
||||
DAABKwIBAUAD/QH/A/MB/wPvAf8D5wH/A80B/wPnAf8D7wH/A+UB/wPGAf8D3gH/A+YB/wPxAf8D/QH/
|
||||
ASsCAQFABAABKwIBAUAD/QH/A/MB/wPvAf8D7wH/A+8B/wPVAf8DcwH/A9QB/wPnAf8D5gH/A+YB/wPx
|
||||
Af8D/QH/ASsCAQFACAABKwIBAUABYwIHAd8BjwGBAX8B/wGlAYsBgAH/AbgBmAGBAf8BwgGkAYgB/wGx
|
||||
AZ0BigH/AXkBbgFkAf8BcQF2AXkB/wGBAZsBuwH/AUgCAgGAFAABKwIBAUABYwIHAd8BjwGBAX8B/wGj
|
||||
AYYBeQH/AZkBewFSAf8BpAGBAWIB/wGxAZ0BigH/AXkBbgFkAf8BcQF2AXkB/wGBAZsBuwH/AUgCAgGA
|
||||
EAABKwIBAUAD9wH/A/EB/wPvAf8D3gH/A4kB/wOaAf8D7wH/A5oB/wOJAf8D1wH/A+YB/wPpAf8D9QH/
|
||||
ASsCAQFABAABKwIBAUAD9wH/A/EB/wPvAf8D7wH/A80B/wOBAf8DqwH/A4EB/wPLAf8D5wH/A+YB/wPp
|
||||
Af8D9QH/ASsCAQFABAABIgIBATABYwIIAd8BnQGSAYYB/wG0AZ0BhwH/AcEBqQGSAf8B0wG8AaYB/wHY
|
||||
AcABoQH/AeEBzAGaAf8BtQGbAYEB/wGSAYcBgQH/AUECAQFwFAABIgIBATABYwIIAd8BnQGSAYYB/wG0
|
||||
AZ0BhwH/AbYBmAGBAf8BhwFiATAB/wGYAXMBQQH/AeEBzAGaAf8BtQGbAYEB/wGSAYcBgQH/AUECAQFw
|
||||
FAABKwIBAUAD9wH/A/AB/wPvAf8D9QH/A+QB/wOBAf8DiAH/A4EB/wPeAf8D7QH/A+YB/wPnAf8D8wH/
|
||||
ASsCAQFABAABKwIBAUAD9wH/A/AB/wPvAf8D1gH/A4EB/wO4Af8D9QH/A7gB/wOBAf8D1AH/A+YB/wPn
|
||||
Af8D8wH/ASsCAQFABAABKwIBAUABmAGVAZIB/wHBAbIBogH/AbgBpAGRAf8B2QHJAbsB/wHbAcoBtgH/
|
||||
Ad4BzAGqAf8B4QHPAaAB/wHeAcgBmgH/AboBpwGVAf8BkQGOAY0B/xQAASsCAQFAAZgBlQGSAf8BwQGy
|
||||
AaIB/wG4AaQBkQH/AcwBtAGeAf8BhwFiATAB/wGYAXMBQQH/AeEBzwGgAf8B3gHIAZoB/wG6AacBlQH/
|
||||
AZEBjgGNAf8UAAErAgEBQAP3Af8D7wH/A/cB/wP3Af8D9wH/A/cB/wNzAf8D9QH/A+8B/wPvAf8D5gH/
|
||||
A+YB/wPzAf8BKwIBAUAEAAErAgEBQAP3Af8D7wH/A/cB/wP3Af8D9wH/A/cB/wNzAf8D9QH/A+8B/wPv
|
||||
Af8D5gH/A+YB/wPzAf8BKwIBAUAEAAErAgEBQAGjAZ8BmQH/AdoBzQG9Af8BrwGWAYEB/wHCAawBlgH/
|
||||
Ab8BqAGQAf8BwAGnAYcB/wG/AaUBgQH/AcEBowGFAf8B0QG3AZ8B/wKBAX0B/xQAASsCAQFAAaMBnwGZ
|
||||
Af8BrQGFAWkB/wGYAXMBQQH/AZgBcwFBAf8BgQFaASgB/wGMAWcBNAH/AZgBcwFBAf8BmAFzAUEB/wGy
|
||||
AY0BdQH/AoEBfQH/FAABKwIBAUAD9wH/A/AB/wPxAf8D3AH/A4EB/wO8Af8D/QH/A7gB/wOBAf8D1gH/
|
||||
A+gB/wPnAf8D8wH/ASsCAQFABAABKwIBAUAD9wH/A/AB/wP3Af8D9wH/A+gB/wODAf8DigH/A4EB/wPh
|
||||
Af8D7wH/A+gB/wPnAf8D8wH/ASsCAQFABAABKwIBAUABpAGhAZoB/wHuAeQB1gH/AYcBYgEwAf8BhwFi
|
||||
ATAB/wGHAWIBMAH/AYcBYgEwAf8BhwFiATAB/wGbAX4BUwH/AdYBvgGpAf8CgQF9Af8UAAErAgEBQAGk
|
||||
AaEBmgH/AaEBgQFdAf8BhwFiATAB/wGHAWIBMAH/AYEBUgEfAf8BgQFaASgB/wGHAWIBMAH/AYcBYgEw
|
||||
Af8BrgGIAXEB/wKBAX0B/xQAASsCAQFAA/cB/wPxAf8D9wH/A/cB/wPTAf8DgQH/A68B/wOBAf8DzQH/
|
||||
A+8B/wPrAf8D6QH/A/UB/wErAgEBQAQAASsCAQFAA/cB/wPxAf8D8wH/A+UB/wOLAf8DnQH/A/cB/wOd
|
||||
Af8DiQH/A94B/wPrAf8D6QH/A/UB/wErAgEBQAQAASsCAQFAAZYBlAGRAf8B5gHeAdIB/wHjAdIBvQH/
|
||||
AeABzwG5Af8B2wHGAbAB/wHXAcEBqwH/AdIBvQGnAf8B0wG9AacB/wHNAb4BsAH/A4EB/xQAASsCAQFA
|
||||
AZYBlAGRAf8B1wHIAbUB/wHjAdIBvQH/AdQBugGeAf8BhwFiATAB/wGYAXMBQQH/AdIBvQGnAf8B0AG4
|
||||
AaEB/wHHAbQBowH/A4EB/xQAASsCAQFAA/0B/wP3Af8D9wH/A/cB/wP3Af8D3AH/A3MB/wPaAf8D7wH/
|
||||
A+8B/wPmAf8D8QH/A/0B/wErAgEBQAQAASsCAQFAA/0B/wP3Af8D9QH/A+4B/wPTAf8D7gH/A/cB/wPt
|
||||
Af8DzQH/A+cB/wPmAf8D8QH/A/0B/wErAgEBQAQAASsCAQFAA5YB/wHKAcQBugH/Av0B/AH/AfgB8gHo
|
||||
Af8B8gHoAdoB/wHrAeEB0wH/AeYB2gHNAf8B4AHUAccB/wGvAacBoQH/A6MB/xQAASsCAQFAA5YB/wHK
|
||||
AcQBugH/Av0B/AH/AeUB1QHCAf8BhwFiATAB/wGYAXMBQQH/AeYB2gHNAf8B4AHUAccB/wGvAacBoQH/
|
||||
A6MB/xgAAUgCAgGAA/0B/wP3Af8D9wH/A/cB/wP3Af8D9wH/A+8B/wPvAf8D7wH/A+8B/wP9Af8BSAIC
|
||||
AYAMAAFIAgIBgAP9Af8D9wH/A/cB/wP3Af8D9wH/A/cB/wPvAf8D7wH/A+8B/wPvAf8D/QH/AUgCAgGA
|
||||
DAABOwIBAWABagIaAe8BygHEAbsB/wHmAd4B0gH/AfMB6gHcAf8B8AHnAdkB/wHiAdkBzQH/Ab0BtgGu
|
||||
Af8BYwIIAd8BIgIBATAYAAE7AgEBYAFqAhoB7wHKAcQBuwH/AdgByAG2Af8BoAGBAV0B/wGuAYYBagH/
|
||||
AeIB2QHNAf8BvQG2Aa4B/wFjAggB3wEiAgEBMBwAAU4CAgGPA/0B/wP4Af8D8gH/A/AB/wPvAf8D7wH/
|
||||
A/AB/wPzAf8D/QH/AU4CAgGPFAABTgICAY8D/QH/A/gB/wPyAf8D8AH/A+8B/wPvAf8D8AH/A/MB/wP9
|
||||
Af8BTgICAY8UAAE7AgEBYAOYAf8BlgGUAZEB/wGjAZ8BmQH/AaQBoAGZAf8BlwGVAZEB/wFjAggB3wEr
|
||||
AgEBQCAAATsCAQFgA5gB/wGWAZQBkQH/AaMBnwGZAf8BpAGgAZkB/wGXAZUBkQH/AWMCCAHfASsCAQFA
|
||||
JAABSAICAYAD/gH/A/kB/wP3Af8D9wH/A/YB/wP1Af8D/QH/AUgCAgGAHAABSAICAYAD/gH/A/kB/wP3
|
||||
Af8D9wH/A/YB/wP1Af8D/QH/AUgCAgGAHAABKwIBAUABKwIBAUABKwIBAUABKwIBAUABKwIBAUABIgIB
|
||||
ATAoAAErAgEBQAErAgEBQAErAgEBQAErAgEBQAErAgEBQAEiAgEBMCwAASsCAQFAASsCAQFAASsCAQFA
|
||||
ASsCAQFAASsCAQFAASsCAQFAASsCAQFAJAABKwIBAUABKwIBAUABKwIBAUABKwIBAUABKwIBAUABKwIB
|
||||
AUABKwIBAUD/ABEAAUIBTQE+BwABPgMAASgDAAFAAwABIAMAAQEBAAEBBgABARYAA/+BAAT/AfgBDwH4
|
||||
AQ8B/wHxAf8B8QHwAQcB8AEHAf8B4QH/AeEB4AEDAeABAwH/AcEB/wHBAcABAQHAAQEB4AEDAeABAwGA
|
||||
AQABgAEAAcABBwHAAQcBgAEAAYABAAGAAQ8BgAEPAYABAAGAAQABgAEPAYABDwGAAQABgAEAAYABDwGA
|
||||
AQ8BgAEAAYABAAGAAQ8BgAEPAYABAAGAAQABgAEPAYABDwGAAQABgAEAAYABDwGAAQ8BwAEBAcABAQHA
|
||||
AQ8BwAEPAeABAwHgAQMB4AEfAeABHwHwAQcB8AEHAfABPwHwAT8B+AEPAfgBDwj/Cw==
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,174 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
partial class MainForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonModify = new System.Windows.Forms.Button();
|
||||
this.listBoxCreatedHostedSweeps = new System.Windows.Forms.ListBox();
|
||||
this.buttonOK = new System.Windows.Forms.Button();
|
||||
this.comboBoxHostedSweepType = new System.Windows.Forms.ComboBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
|
||||
this.buttonCreate.Location = new System.Drawing.Point(12, 295);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(68, 23);
|
||||
this.buttonCreate.TabIndex = 1;
|
||||
this.buttonCreate.Text = "&Create...";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||
//
|
||||
// buttonModify
|
||||
//
|
||||
this.buttonModify.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
|
||||
this.buttonModify.Enabled = false;
|
||||
this.buttonModify.Location = new System.Drawing.Point(86, 295);
|
||||
this.buttonModify.Name = "buttonModify";
|
||||
this.buttonModify.Size = new System.Drawing.Size(68, 23);
|
||||
this.buttonModify.TabIndex = 3;
|
||||
this.buttonModify.Text = "&Modify...";
|
||||
this.buttonModify.UseVisualStyleBackColor = true;
|
||||
this.buttonModify.Click += new System.EventHandler(this.buttonModify_Click);
|
||||
//
|
||||
// listBoxCreatedHostedSweeps
|
||||
//
|
||||
this.listBoxCreatedHostedSweeps.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listBoxCreatedHostedSweeps.FormattingEnabled = true;
|
||||
this.listBoxCreatedHostedSweeps.Location = new System.Drawing.Point(12, 87);
|
||||
this.listBoxCreatedHostedSweeps.Name = "listBoxCreatedHostedSweeps";
|
||||
this.listBoxCreatedHostedSweeps.Size = new System.Drawing.Size(216, 199);
|
||||
this.listBoxCreatedHostedSweeps.TabIndex = 4;
|
||||
this.listBoxCreatedHostedSweeps.SelectedValueChanged += new System.EventHandler(this.listBoxHostedSweeps_SelectedValueChanged);
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom;
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonOK.Location = new System.Drawing.Point(160, 295);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(68, 23);
|
||||
this.buttonOK.TabIndex = 5;
|
||||
this.buttonOK.Text = "&OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click);
|
||||
//
|
||||
// comboBoxHostedSweepType
|
||||
//
|
||||
this.comboBoxHostedSweepType.FormattingEnabled = true;
|
||||
this.comboBoxHostedSweepType.Location = new System.Drawing.Point(12, 31);
|
||||
this.comboBoxHostedSweepType.Name = "comboBoxHostedSweepType";
|
||||
this.comboBoxHostedSweepType.Size = new System.Drawing.Size(216, 21);
|
||||
this.comboBoxHostedSweepType.TabIndex = 6;
|
||||
this.comboBoxHostedSweepType.SelectedIndexChanged += new System.EventHandler(this.comboBoxHostedSweepType_SelectedIndexChanged);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(9, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(141, 13);
|
||||
this.label1.TabIndex = 7;
|
||||
this.label1.Text = "Select a hosted sweep type:";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 66);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(202, 13);
|
||||
this.label2.TabIndex = 8;
|
||||
this.label2.Text = "Select a created hosted sweep to modify:";
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
this.AcceptButton = this.buttonOK;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.buttonOK;
|
||||
this.ClientSize = new System.Drawing.Size(240, 330);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.listBoxCreatedHostedSweeps);
|
||||
this.Controls.Add(this.comboBoxHostedSweepType);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.Controls.Add(this.buttonModify);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "MainForm";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Hosted Sweep";
|
||||
this.Load += new System.EventHandler(this.MainForm_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button buttonCreate;
|
||||
private System.Windows.Forms.Button buttonModify;
|
||||
private System.Windows.Forms.Button buttonOK;
|
||||
private System.Windows.Forms.ListBox listBoxCreatedHostedSweeps;
|
||||
private System.Windows.Forms.ComboBox comboBoxHostedSweepType;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the main form. It is the entry to create a new hosted sweep or to modify
|
||||
/// a created hosted sweep.
|
||||
/// </summary>
|
||||
public partial class MainForm : System.Windows.Forms.Form
|
||||
{
|
||||
/// <summary>
|
||||
/// Encapsulates the data source for a form.
|
||||
/// </summary>
|
||||
BindingSource m_binding;
|
||||
|
||||
/// <summary>
|
||||
/// Creation manager, which collects all the creators.
|
||||
/// </summary>
|
||||
private CreationMgr m_creationMgr;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Customize constructor.
|
||||
/// </summary>
|
||||
/// <param name="mgr"></param>
|
||||
public MainForm(CreationMgr mgr): this()
|
||||
{
|
||||
m_creationMgr = mgr;
|
||||
m_binding = new BindingSource();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a form to fetch edges for hosted-sweep creation, and then create
|
||||
/// the hosted-sweep.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
HostedSweepCreator creator =
|
||||
comboBoxHostedSweepType.SelectedItem as HostedSweepCreator;
|
||||
|
||||
CreationData creationData = new CreationData(creator);
|
||||
|
||||
using (EdgeFetchForm createForm = new EdgeFetchForm(creationData))
|
||||
{
|
||||
if (createForm.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
creator.Create(creationData);
|
||||
RefreshListBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show a form to modify the created hosted-sweep.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
ModificationData modificationData = listBoxCreatedHostedSweeps.SelectedItem as ModificationData;
|
||||
|
||||
using(HostedSweepModifyForm modifyForm = new HostedSweepModifyForm(modificationData))
|
||||
{
|
||||
modifyForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refresh list box data source.
|
||||
/// </summary>
|
||||
private void RefreshListBox()
|
||||
{
|
||||
HostedSweepCreator creator =
|
||||
comboBoxHostedSweepType.SelectedItem as HostedSweepCreator;
|
||||
m_binding.DataSource = creator.CreatedHostedSweeps;
|
||||
listBoxCreatedHostedSweeps.DataSource = m_binding;
|
||||
listBoxCreatedHostedSweeps.DisplayMember = "Name";
|
||||
m_binding.ResetBindings(false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize combobox data source.
|
||||
/// </summary>
|
||||
private void InitializeComboBox()
|
||||
{
|
||||
comboBoxHostedSweepType.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxHostedSweepType.Items.Add(m_creationMgr.FasciaCreator);
|
||||
comboBoxHostedSweepType.Items.Add(m_creationMgr.GutterCreator);
|
||||
comboBoxHostedSweepType.Items.Add(m_creationMgr.SlabEdgeCreator);
|
||||
comboBoxHostedSweepType.SelectedIndex = 0;
|
||||
comboBoxHostedSweepType.DisplayMember = "Name";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize combo-box.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void MainForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
InitializeComboBox();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Close this form.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void buttonOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update "Modify" button status according to the list-box selection item.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void listBoxHostedSweeps_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (listBoxCreatedHostedSweeps.SelectedItem != null)
|
||||
buttonModify.Enabled = true;
|
||||
else
|
||||
buttonModify.Enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the list-box data source according to the combobox selection.
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void comboBoxHostedSweepType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
RefreshListBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,401 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Autodesk.Revit.DB;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is intent to display element's wire-frame with C# GDI.
|
||||
/// It contains a solid and a bounding box of an element.
|
||||
/// It also contains transformation (translation, rotation and scale) to
|
||||
/// transform the geometry edges.
|
||||
/// </summary>
|
||||
public class ElementGeometry
|
||||
{
|
||||
/// <summary>
|
||||
/// Element's Solid
|
||||
/// </summary>
|
||||
private Solid m_solid;
|
||||
|
||||
/// <summary>
|
||||
/// Solid bounding box minimal corner.
|
||||
/// </summary>
|
||||
private XYZ m_bBoxMin;
|
||||
|
||||
/// <summary>
|
||||
/// Solid bounding box maximal corner.
|
||||
/// </summary>
|
||||
private XYZ m_bBoxMax;
|
||||
|
||||
/// <summary>
|
||||
/// Translation transform, it is intent to translate the solid.
|
||||
/// It is actually the center of Bounding box.
|
||||
/// </summary>
|
||||
private XYZ m_translation;
|
||||
|
||||
/// <summary>
|
||||
/// Scale transform, it is intent to scale the solid.
|
||||
/// </summary>
|
||||
private double m_scale;
|
||||
|
||||
/// <summary>
|
||||
/// Rotation transform, it is intent to rotate the solid.
|
||||
/// </summary>
|
||||
private Transform m_rotation;
|
||||
|
||||
/// <summary>
|
||||
/// If the solid is transformed (includes translation, scale and rotation)
|
||||
/// this flag should be true, otherwise false.
|
||||
/// </summary>
|
||||
private bool m_isDirty;
|
||||
|
||||
/// <summary>
|
||||
/// Solid's Edge to EdgeBinding dictionary. It is intent to store all the edges
|
||||
/// of solid.
|
||||
/// </summary>
|
||||
private Dictionary<Edge, EdgeBinding> m_edgeBindinDic;
|
||||
|
||||
/// <summary>
|
||||
/// Translation transform, it is intent to translate the solid.
|
||||
/// It is actually the center of Bounding box.
|
||||
/// </summary>
|
||||
public XYZ Translation
|
||||
{
|
||||
get { return m_translation; }
|
||||
set
|
||||
{
|
||||
m_isDirty = true;
|
||||
m_translation = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Scale transform, it is intent to scale the solid.
|
||||
/// </summary>
|
||||
public double Scale
|
||||
{
|
||||
get { return m_scale; }
|
||||
set
|
||||
{
|
||||
m_isDirty = true;
|
||||
m_scale = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Rotation transform, it is intent to rotate the solid.
|
||||
/// </summary>
|
||||
public Transform Rotation
|
||||
{
|
||||
get { return m_rotation; }
|
||||
set
|
||||
{
|
||||
m_isDirty = true;
|
||||
m_rotation = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Element's Solid
|
||||
/// </summary>
|
||||
public Solid Solid
|
||||
{
|
||||
get { return m_solid; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Solid's Edge to EdgeBinding dictionary. It is intent to store all the edges
|
||||
/// of solid.
|
||||
/// </summary>
|
||||
public Dictionary<Edge, EdgeBinding> EdgeBindingDic
|
||||
{
|
||||
get { return m_edgeBindinDic; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor, Construct a new object with an element's geometry Solid,
|
||||
/// and its corresponding bounding box.
|
||||
/// </summary>
|
||||
/// <param name="solid">Element's geometry Solid</param>
|
||||
/// <param name="box">Element's geometry bounding box</param>
|
||||
public ElementGeometry(Solid solid, BoundingBoxXYZ box)
|
||||
{
|
||||
m_solid = solid;
|
||||
m_bBoxMin = box.Min;
|
||||
m_bBoxMax = box.Max;
|
||||
m_isDirty = true;
|
||||
|
||||
// Initialize edge binding
|
||||
m_edgeBindinDic = new Dictionary<Edge, EdgeBinding>();
|
||||
foreach (Edge edge in m_solid.Edges)
|
||||
{
|
||||
EdgeBinding edgeBingding = new EdgeBinding(edge);
|
||||
m_edgeBindinDic.Add(edge, edgeBingding);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize the transform (includes translation, scale, and rotation).
|
||||
/// </summary>
|
||||
/// <param name="width">Width of the view</param>
|
||||
/// <param name="height">Height of the view</param>
|
||||
public void InitializeTransform(double width, double height)
|
||||
{
|
||||
// Initialize translation and rotation transform
|
||||
XYZ bBoxCenter = (m_bBoxMax + m_bBoxMin) / 2.0;
|
||||
m_translation = -bBoxCenter;
|
||||
m_rotation = Transform.Identity;
|
||||
|
||||
// Initialize scale factor
|
||||
double bBoxWidth = m_bBoxMax.X - m_bBoxMin.X;
|
||||
double bBoxHeight = m_bBoxMax.Y - m_bBoxMin.Y;
|
||||
double widthScale = width / bBoxWidth;
|
||||
double heigthScale = height / bBoxHeight;
|
||||
m_scale = Math.Min(widthScale, heigthScale);
|
||||
|
||||
// Set dirty flag
|
||||
m_isDirty = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset all the edges' status to their original status.
|
||||
/// </summary>
|
||||
public void ResetEdgeStates()
|
||||
{
|
||||
foreach (KeyValuePair<Edge, EdgeBinding> pair in m_edgeBindinDic)
|
||||
{
|
||||
pair.Value.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update all the edges' transform (include translation, scale, and rotation),
|
||||
/// reconstruct the edge's geometry info.
|
||||
/// </summary>
|
||||
private void Update()
|
||||
{
|
||||
if (!m_isDirty) return;
|
||||
|
||||
foreach (KeyValuePair<Edge, EdgeBinding> pair in m_edgeBindinDic)
|
||||
{
|
||||
pair.Value.Update(m_rotation, m_translation, m_scale);
|
||||
}
|
||||
m_isDirty = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw all the edges of solid in Graphics.
|
||||
/// </summary>
|
||||
/// <param name="g">Graphics, edges will be draw in it</param>
|
||||
public void Draw(Graphics g)
|
||||
{
|
||||
Update();
|
||||
foreach (KeyValuePair<Edge, EdgeBinding> pair in m_edgeBindinDic)
|
||||
{
|
||||
pair.Value.Draw(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Binds an edge with some properties which contains its geometry information
|
||||
/// and indicates whether the edge is selected or highlighted.
|
||||
/// </summary>
|
||||
public class EdgeBinding : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Edge points in world coordinate system of Revit.
|
||||
/// </summary>
|
||||
private IList<XYZ> m_points;
|
||||
|
||||
/// <summary>
|
||||
/// Edge geometry presentation in C# GDI.
|
||||
/// </summary>
|
||||
private GraphicsPath m_gdiEdge;
|
||||
|
||||
/// <summary>
|
||||
/// Edge bounding Region used to hit testing.
|
||||
/// </summary>
|
||||
private Region m_region;
|
||||
|
||||
/// <summary>
|
||||
/// Pen for edge display.
|
||||
/// </summary>
|
||||
private Pen m_pen;
|
||||
|
||||
/// <summary>
|
||||
/// A flag to indicate the edge is highlighted or not.
|
||||
/// </summary>
|
||||
private bool m_isHighLighted;
|
||||
|
||||
/// <summary>
|
||||
/// A flag to indicate the edge is selected or not.
|
||||
/// </summary>
|
||||
private bool m_isSelected;
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the edge is highlighted or not.
|
||||
/// </summary>
|
||||
public bool IsHighLighted
|
||||
{
|
||||
get { return m_isHighLighted; }
|
||||
set { m_isHighLighted = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the edge is selected or not.
|
||||
/// </summary>
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return m_isSelected; }
|
||||
set { m_isSelected = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructor takes Edge as parameter.
|
||||
/// </summary>
|
||||
/// <param name="edge">Edge</param>
|
||||
public EdgeBinding(Edge edge)
|
||||
{
|
||||
m_points = edge.Tessellate();
|
||||
m_pen = new Pen(System.Drawing.Color.White);
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reset the status of the edge: un-highlighted, un-selected
|
||||
/// </summary>
|
||||
public void Reset()
|
||||
{
|
||||
m_isHighLighted = false;
|
||||
m_isSelected = false;
|
||||
m_region = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update the edge's geometry according to the transformation.
|
||||
/// </summary>
|
||||
/// <param name="rotation">Rotation transform</param>
|
||||
/// <param name="translation">Translation transform</param>
|
||||
/// <param name="scale">Scale transform</param>
|
||||
public void Update(Transform rotation, XYZ translation, double scale)
|
||||
{
|
||||
rotation = rotation.Inverse;
|
||||
PointF[] points = new PointF[m_points.Count];
|
||||
for (int i = 0; i < m_points.Count; i++)
|
||||
{
|
||||
XYZ tmpPt = m_points[i];
|
||||
tmpPt = rotation.OfPoint((tmpPt + translation) * scale);
|
||||
points[i] = new PointF((float)tmpPt.X, (float)tmpPt.Y);
|
||||
}
|
||||
if (m_gdiEdge != null) m_gdiEdge.Dispose();
|
||||
m_gdiEdge = new GraphicsPath();
|
||||
m_gdiEdge.AddLines(points);
|
||||
|
||||
if (m_region != null) m_region.Dispose();
|
||||
m_region = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draw the edge in Graphics.
|
||||
/// </summary>
|
||||
/// <param name="g">Graphics</param>
|
||||
public void Draw(Graphics g)
|
||||
{
|
||||
m_pen.Width = 2.0f;
|
||||
if (m_isHighLighted)
|
||||
{
|
||||
m_pen.Color = System.Drawing.Color.Yellow;
|
||||
}
|
||||
else if (m_isSelected)
|
||||
{
|
||||
m_pen.Color = System.Drawing.Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pen.Color = System.Drawing.Color.Green;
|
||||
}
|
||||
g.DrawPath(m_pen, m_gdiEdge);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return the Edge Region.
|
||||
/// </summary>
|
||||
/// <returns>Region of the edge</returns>
|
||||
private Region GetRegion()
|
||||
{
|
||||
if (m_region == null)
|
||||
{
|
||||
GraphicsPath tmpPath = new GraphicsPath();
|
||||
tmpPath.AddLines(m_gdiEdge.PathPoints);
|
||||
Pen tmpPen = new Pen(System.Drawing.Color.White, 3.0f);
|
||||
tmpPath.Widen(tmpPen);
|
||||
m_region = new Region(tmpPath);
|
||||
}
|
||||
return m_region;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test whether or not the edge is under a specified location.
|
||||
/// </summary>
|
||||
/// <param name="x">X coordinate</param>
|
||||
/// <param name="y">Y coordinate</param>
|
||||
/// <returns></returns>
|
||||
private bool HitTest(float x, float y)
|
||||
{
|
||||
return this.GetRegion().IsVisible(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the edge under the location (x, y), set the highlight flag to true,
|
||||
/// otherwise false.
|
||||
/// </summary>
|
||||
/// <param name="x">X coordinate</param>
|
||||
/// <param name="y">Y coordinate</param>
|
||||
/// <returns></returns>
|
||||
public bool HighLight(float x, float y)
|
||||
{
|
||||
m_isHighLighted = HitTest(x, y);
|
||||
return m_isHighLighted;
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <summary>
|
||||
/// Dispose
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
m_gdiEdge.Dispose();
|
||||
m_pen.Dispose();
|
||||
m_region.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
using Autodesk.Revit.DB;
|
||||
using System.Windows.Forms;
|
||||
using Point = System.Drawing.Point;
|
||||
|
||||
namespace Revit.SDK.Samples.NewHostedSweep.CS
|
||||
{
|
||||
/// <summary>
|
||||
/// This class is intent to convenience the geometry transformations.
|
||||
/// It can produce rotation and scale transformations.
|
||||
/// </summary>
|
||||
public class TrackBall
|
||||
{
|
||||
/// <summary>
|
||||
/// Canvas width.
|
||||
/// </summary>
|
||||
private float m_canvasWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Canvas height.
|
||||
/// </summary>
|
||||
private float m_canvasHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Previous position in 2D.
|
||||
/// </summary>
|
||||
private Point m_previousPosition2D;
|
||||
|
||||
/// <summary>
|
||||
/// Previous position in 3D.
|
||||
/// </summary>
|
||||
private XYZ m_previousPosition3D;
|
||||
|
||||
/// <summary>
|
||||
/// Current rotation transform.
|
||||
/// </summary>
|
||||
private Transform m_rotation = Transform.Identity;
|
||||
|
||||
/// <summary>
|
||||
/// Current scale transform.
|
||||
/// </summary>
|
||||
private double m_scale;
|
||||
|
||||
/// <summary>
|
||||
/// Current rotation transform.
|
||||
/// </summary>
|
||||
public Transform Rotation
|
||||
{
|
||||
get { return m_rotation; }
|
||||
set { m_rotation = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current scale transform.
|
||||
/// </summary>
|
||||
public double Scale
|
||||
{
|
||||
get { return m_scale; }
|
||||
set { m_scale = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Project canvas 2D point to the track ball.
|
||||
/// </summary>
|
||||
/// <param name="width">Canvas width</param>
|
||||
/// <param name="height">Canvas height</param>
|
||||
/// <param name="point">2D point</param>
|
||||
/// <returns>Projected point in track ball</returns>
|
||||
private XYZ ProjectToTrackball(double width, double height, Point point)
|
||||
{
|
||||
double x = point.X / (width / 2); // Scale so bounds map to [0,0] - [2,2]
|
||||
double y = point.Y / (height / 2);
|
||||
|
||||
x = x - 1; // Translate 0,0 to the center
|
||||
y = 1 - y; // Flip so +Y is up instead of down
|
||||
|
||||
double d, t, z;
|
||||
|
||||
d = Math.Sqrt(x * x + y * y);
|
||||
if (d < 0.70710678118654752440)
|
||||
{ /* Inside sphere */
|
||||
z = Math.Sqrt(1 - d * d);
|
||||
}
|
||||
else
|
||||
{ /* On hyperbola */
|
||||
t = 1 / 1.41421356237309504880;
|
||||
z = t * t / d;
|
||||
}
|
||||
return new XYZ(x, y, z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Yield the rotation transform according to current 2D point in canvas.
|
||||
/// </summary>
|
||||
/// <param name="currentPosition">2D point in canvas</param>
|
||||
private void Track(Point currentPosition)
|
||||
{
|
||||
XYZ currentPosition3D = ProjectToTrackball(
|
||||
m_canvasWidth, m_canvasHeight, currentPosition);
|
||||
|
||||
XYZ axis = m_previousPosition3D.CrossProduct(currentPosition3D);
|
||||
if (axis.GetLength() == 0) return;
|
||||
|
||||
double angle = m_previousPosition3D.AngleTo(currentPosition3D);
|
||||
m_rotation = Transform.CreateRotation(axis, -angle);
|
||||
m_previousPosition3D = currentPosition3D;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Yield the scale transform according to current 2D point in canvas.
|
||||
/// </summary>
|
||||
/// <param name="currentPosition">2D point in canvas</param>
|
||||
private void Zoom(Point currentPosition)
|
||||
{
|
||||
double yDelta = currentPosition.Y - m_previousPosition2D.Y;
|
||||
|
||||
double scale = Math.Exp(yDelta / 100); // e^(yDelta/100) is fairly arbitrary.
|
||||
|
||||
m_scale = scale;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mouse down, initialize the transformation to identity.
|
||||
/// </summary>
|
||||
/// <param name="width">Canvas width</param>
|
||||
/// <param name="height">Canvas height</param>
|
||||
/// <param name="e"></param>
|
||||
public void OnMouseDown(float width, float height, MouseEventArgs e)
|
||||
{
|
||||
m_rotation = Transform.Identity;
|
||||
m_scale = 1.0;
|
||||
m_canvasWidth = width;
|
||||
m_canvasHeight = height;
|
||||
m_previousPosition2D = e.Location;
|
||||
m_previousPosition3D = ProjectToTrackball(m_canvasWidth,
|
||||
m_canvasHeight,
|
||||
m_previousPosition2D);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mouse move with left button press will yield the rotation transform,
|
||||
/// with right button press will yield scale transform.
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
Point currentPosition = e.Location;
|
||||
|
||||
// avoid any zero axis conditions
|
||||
if (currentPosition == m_previousPosition2D) return;
|
||||
|
||||
// Prefer tracking to zooming if both buttons are pressed.
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
Track(currentPosition);
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
Zoom(currentPosition);
|
||||
}
|
||||
|
||||
m_previousPosition2D = currentPosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Arrows key down will also yield the rotation transform.
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
public void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
XYZ axis = new XYZ(1.0, 0, 0);
|
||||
double angle = 0.1;
|
||||
switch (e.KeyCode)
|
||||
{
|
||||
case Keys.Down: break;
|
||||
case Keys.Up:
|
||||
angle = -angle;
|
||||
break;
|
||||
case Keys.Left:
|
||||
axis = new XYZ(0, 1.0, 0);
|
||||
angle = -angle;
|
||||
break;
|
||||
case Keys.Right:
|
||||
axis = new XYZ(0, 1.0, 0);
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
m_rotation = Transform.CreateRotation(axis, angle);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 938 B |
Binary file not shown.
|
After Width: | Height: | Size: 938 B |
Binary file not shown.
|
After Width: | Height: | Size: 938 B |
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RevitAddIns>
|
||||
<AddIn Type="Command">
|
||||
<Assembly>NewHostedSweep.dll</Assembly>
|
||||
<ClientId>06b26178-0b22-4256-b498-f4f17dccfca1</ClientId>
|
||||
<FullClassName>Revit.SDK.Samples.NewHostedSweep.CS.Command</FullClassName>
|
||||
<Text>New hosted sweep</Text>
|
||||
<Description>Create hosted sweep and modify created hosted sweep</Description>
|
||||
<VisibilityMode>AlwaysVisible</VisibilityMode>
|
||||
<VendorId>ADSK</VendorId>
|
||||
<VendorDescription>Autodesk, www.autodesk.com</VendorDescription>
|
||||
</AddIn>
|
||||
</RevitAddIns>
|
||||
@@ -0,0 +1,136 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>9.0.30729</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{BB5C52F3-93FC-441C-91D4-758182CC2747}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Revit.SDK.Samples.NewHostedSweep.CS</RootNamespace>
|
||||
<AssemblyName>NewHostedSweep</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<DocumentationFile>
|
||||
</DocumentationFile>
|
||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core">
|
||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Command.cs" />
|
||||
<Compile Include="Data\CreationData.cs" />
|
||||
<Compile Include="Forms\CreationDataTypeConvertor.cs" />
|
||||
<Compile Include="Creators\CreationMgr.cs" />
|
||||
<Compile Include="Forms\EdgeFormUITypeEditor.cs" />
|
||||
<Compile Include="Geom\ElementGeometry.cs" />
|
||||
<Compile Include="Creators\FasciaCreator.cs" />
|
||||
<Compile Include="Forms\MainForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\MainForm.Designer.cs">
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Creators\GutterCreator.cs" />
|
||||
<Compile Include="Creators\HostedSweepCreator.cs" />
|
||||
<Compile Include="Forms\HostedSweepModifyForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\HostedSweepModifyForm.Designer.cs">
|
||||
<DependentUpon>HostedSweepModifyForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EdgeFetchForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\EdgeFetchForm.Designer.cs">
|
||||
<DependentUpon>EdgeFetchForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Data\ModificationData.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Creators\SlabEdgeCreator.cs" />
|
||||
<Compile Include="Geom\TrackBall.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Forms\MainForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>MainForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\HostedSweepModifyForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>HostedSweepModifyForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Forms\EdgeFetchForm.resx">
|
||||
<SubType>Designer</SubType>
|
||||
<DependentUpon>EdgeFetchForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Images\CBChecked.bmp" />
|
||||
<Content Include="Images\CBIndeterminate.bmp" />
|
||||
<Content Include="Images\CBUnchecked.bmp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(SolutionDir)VSProps\SDKSamples.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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>set FILEFORSAMPLEREG="$(SolutionDir)..\..\..\..\Regression\API\SDKSamples\UpdateSampleDllForRegression.pl"
|
||||
if exist %25FILEFORSAMPLEREG%25 perl %25FILEFORSAMPLEREG%25 $(ProjectExt) "$(ProjectPath)" "$(TargetPath)" "$(SolutionDir)"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>None</ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// (C) Copyright 2003-2019 by Autodesk, Inc.
|
||||
//
|
||||
// Permission to use, copy, modify, and distribute this software in
|
||||
// object code form for any purpose and without fee is hereby granted,
|
||||
// provided that the above copyright notice appears in all copies and
|
||||
// that both that copyright notice and the limited warranty and
|
||||
// restricted rights notice below appear in all supporting
|
||||
// documentation.
|
||||
//
|
||||
// AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS.
|
||||
// AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF
|
||||
// MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC.
|
||||
// DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE
|
||||
// UNINTERRUPTED OR ERROR FREE.
|
||||
//
|
||||
// Use, duplication, or disclosure by the U.S. Government is subject to
|
||||
// restrictions set forth in FAR 52.227-19 (Commercial Computer
|
||||
// Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
|
||||
// (Rights in Technical Data and Computer Software), as applicable.
|
||||
//
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("NewHostedSweep")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("NewHostedSweep")]
|
||||
[assembly: AssemblyCopyright("Copyright © Autodesk, Inc. 2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a12e7c76-6df1-4f01-a01e-aae6c939cd5c")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
Binary file not shown.
Reference in New Issue
Block a user