PDA

View Full Version : [C#] Utilizzare ElementSet in classi diverse


R1((ky
24-10-2008, 16:09
Salve di nuovo, sto iniziano a sviluppare un'applicaztivo in C# per Autodesk Revit, pur non conoscendo il C# :D

Ci sono quasi, però ho qualche difficoltà nel richiamare funzioni public da altre classi (o namespace).


In particolare, in una classe ho queste righe:


public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// set out default result to failure.
IExternalCommand.Result retRes = IExternalCommand.Result.Failed;

Autodesk.Revit.Application app = commandData.Application;

// get the elements selected
// The current selection can be retrieved from the active
// document via the selection object

SelElementSet selection = app.ActiveDocument.Selection.Elements;

..................


poi in un'altra classe dovrei utilizzare il SelElementSet selection, ma non riesco ad accedervi.

La classe è public, ma come mai non riesco? Come dovrei fare?

Grazie per la pazienza

Rank-1
24-10-2008, 20:17
ciao, sinceramente non ho capito..
però se devi accedere a SelElementSet selection da un'altra classe perchè lo dichiari all'interno della funzione Execute? quando questa finisce SelElementSet muore con essa..

esempio:


public class myclass
{
public SelElementSet selection;

public IExternalCommand.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
// set out default result to failure.
IExternalCommand.Result retRes = IExternalCommand.Result.Failed;

Autodesk.Revit.Application app = commandData.Application;

// get the elements selected
// The current selection can be retrieved from the active
// document via the selection object

selection = app.ActiveDocument.Selection.Elements;

}

(dall'altra classe)
cc.Execute(....)
cc.selection