Help me to change the Code in Sharp Develop from Application to Project Macro!!

Help me to change the Code in Sharp Develop from Application to Project Macro!!

mahbubulkabir
Explorer Explorer
465 Views
3 Replies
Message 1 of 4

Help me to change the Code in Sharp Develop from Application to Project Macro!!

mahbubulkabir
Explorer
Explorer

Please help me to change the code to Project macro writing...

I've a code like this:

 

    UIDocument uidoc= this.ActiveUIDocument;
            Document doc= uidoc.Document;

 

How do I convert it for project?

0 Likes
466 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Please clearify, what are you planning to do with your macro ? uidoc.Document IS your project, so there is no need for conversion.
Message 3 of 4

Troy_Gates
Advocate
Advocate

This is what I use to get the document in an Application Macro:

 

Document doc = this.ActiveUIDocument.Document;

 

 

 

Message 4 of 4

mahbubulkabir
Explorer
Explorer

i want to change below macro from Aplication macro to Project Macro:

public
Void CropViewBySelectionCS()
{
UIDocument uidoc= this.ActiveUIDocument;
Document doc= uidoc.Document;
IList<Reference> refs= uidoc.Selection.PickObjects(ObjectType.Element,"Make a selection, click on finish when done");
View v = doc.ActiveView;
List<XYZ> points = new List<XYZ>();
if(v.ViewType == ViewType.FloorPlan)
{
foreach(Reference r in refs)
{
BoundingBoxXYZ bb= doc.GetElement(r).get_BoundingBox(v);
points.Add(bb.Min);
points.Add(bb.Max);
}
BoundingBoxXYZ sb= new BoundingBoxXYZ();
sb.Min=new XYZ(points.Min(p=> p.X),
points.Min(p=> p.Y),
points.Min(p=> p.Z));
sb.Max=new XYZ(points.Max(p=> p.X),
points.Max(p=> p.Y),
points.Max(p=> p.Z));
try {
using (Transaction t = new Transaction(doc,"Crop View By Selection")) {
t.Start();
v.CropBoxActive=true;
v.CropBox=sb;
t.Commit();
}
} catch (Exception ex) {
TaskDialog.Show("Revit",ex.Message);
return;
}
}

 

How i can do it! Please help...

0 Likes