Generate 3D View Programmatically

Anonymous

Generate 3D View Programmatically

Anonymous
Not applicable

Hi,

 

if i select imperial or metric template there is no 3DView listed in view by default(Revit 2015), so i want to generate 3DView programmatically,

how to achieve it.

 

Thanks in advance,

 

Regards

Kailash

Reply
Accepted solutions (1)
9,497 Views
7 Replies
Replies (7)

jeremytammik
Autodesk
Autodesk

Dear Kailash,

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.37

 

Certainly you could have found this yourself?

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes

Revitalizer
Advisor
Advisor
Accepted solution

Hi,

 

if you want to create default {3D}, you can use:

 

RevitCommandId commandId = RevitCommandId.LookupPostableCommandId(PostableCommand.Default3DView);

if (commandData.Application.CanPostCommand(commandId))
{
    commandData.Application.PostCommand(commandId);
}

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes

Anonymous
Not applicable

Thank you Jeremy sir,

 

Below is the working code which you have already mentioned in Exporting Image and Setting a Default 3D View Orientation

 

i picked up this one

 

                     var direction = new XYZ(-1, 1, -1);
                        var collector = new FilteredElementCollector(Doc);
                        var viewFamilyType = collector.OfClass(typeof(ViewFamilyType)).Cast<ViewFamilyType>()
                          .FirstOrDefault(x => x.ViewFamily == ViewFamily.ThreeDimensional);

                        using (Transaction ttNew = new Transaction(Doc, "abc"))
                        {
                            ttNew.Start();
                            var view3D = View3D.CreateIsometric(
                                              Doc, viewFamilyType.Id);

                            view3D.SetOrientation(new ViewOrientation3D(
                              direction, new XYZ(0, 1, 1), new XYZ(0, 1, -1)));
                            ttNew.Commit();

                        }

 

Regards

Kailash Smiley Very Happy

Anonymous
Not applicable

Thank you Revitalizer,

 

your posted code is also working, just i placed it in a proper location in my project.and done.

 

Regards

Kailash Smiley Very Happy

0 Likes

BIM_S_S
Participant
Participant

it work when i open one document only

not working with multiple documents

0 Likes

Revitalizer
Advisor
Advisor

Hi,

 

yes, of course, it works with the active document.

The function simulates the user clicking the related button, as all the postable commands do.

 

Works as exspected, I would say.

 

 

Revitalizer




Rudolf Honke
Software Developer
Mensch und Maschine





0 Likes

pccheung
Contributor
Contributor

Dear Revitalizer,

I have lines of code of about TaskDialog.Show() after the postable command. But i don't know why the taskdialog is executed before the postable command, what mistake did i make?

 

Moreover, I have create the default {3D} view with the postable command, how should I make the {3D} view active and set a section box on it? 

 

I found that the postable command