Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a ViewPlan and Crop it

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
BenoitE&A
2654 Views, 3 Replies

Create a ViewPlan and Crop it

BenoitE&A
Collaborator
Collaborator

Hello,

Sorry if this topic is solved I've been searching for a while without success.

So here is what I want to do : 

- I have a CurveLoop which is valid to crop my active view

- I create a new ViewPlan

- I want to crop it

Everything works fine except the last.

 

Here is my code :

 

using (Transaction t = new Transaction(uidoc.Document, "Renomme les vues selectionnees"))
            {
                t.Start();
                ViewPlan maVue = ViewPlan.Create(doc, floorPlanId, doc.ActiveView.GenLevel.Id);

                // Appliquer un gabarit sur ma vue (viewTemplate), changer son nom, etc...

               
                // On crope
                ViewCropRegionShapeManager vcrShapeMgr = maVue.GetCropRegionShapeManager();
               
                if (vcrShapeMgr.CanHaveShape) vcrShapeMgr.SetCropShape(cl); else TaskDialog.Show("r", "Je ne peux pas croper à la forme demandée");
                t.Commit();
            }

 

Another question: I would like to set my view name and apply a view Template to my new view. I can't find out how.

Thanks

Benoit

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes

Create a ViewPlan and Crop it

Hello,

Sorry if this topic is solved I've been searching for a while without success.

So here is what I want to do : 

- I have a CurveLoop which is valid to crop my active view

- I create a new ViewPlan

- I want to crop it

Everything works fine except the last.

 

Here is my code :

 

using (Transaction t = new Transaction(uidoc.Document, "Renomme les vues selectionnees"))
            {
                t.Start();
                ViewPlan maVue = ViewPlan.Create(doc, floorPlanId, doc.ActiveView.GenLevel.Id);

                // Appliquer un gabarit sur ma vue (viewTemplate), changer son nom, etc...

               
                // On crope
                ViewCropRegionShapeManager vcrShapeMgr = maVue.GetCropRegionShapeManager();
               
                if (vcrShapeMgr.CanHaveShape) vcrShapeMgr.SetCropShape(cl); else TaskDialog.Show("r", "Je ne peux pas croper à la forme demandée");
                t.Commit();
            }

 

Another question: I would like to set my view name and apply a view Template to my new view. I can't find out how.

Thanks

Benoit

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
3 REPLIES 3
Message 2 of 4
BenoitE&A
in reply to: BenoitE&A

BenoitE&A
Collaborator
Collaborator

I forgot to add that the problem is that my crop region is not a rectangle, so the parameter vcrShapeMgr.CanHaveShape is false. Which is my problem...

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes

I forgot to add that the problem is that my crop region is not a rectangle, so the parameter vcrShapeMgr.CanHaveShape is false. Which is my problem...

 


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
Message 3 of 4
RPTHOMAS108
in reply to: BenoitE&A

RPTHOMAS108
Mentor
Mentor
Accepted solution

I believe when you are working with a newly created view the .CanHaveShape property will be set to false until you have first made the crop region visible.

 

Visibility and active status can be set via properties of the class:


View.CropBoxVisible = True

View.CropBoxActive =True

 

Do the above first in a subtransaction and then you should be able to apply a shape.

 

ViewTemplates are indicated by built in parameters:

VIEW_TEMPLATE_FOR_SCHEDULE

VIEW_TEMPLATE

 

These can be set by the property of the class e.g. View.ViewTemplateID

 

View templates are objects in the database which share the same class as the views they can be applied to i.e. ViewPlan will have a property ViewPlan.IsTemplate to identify that object as a template not a view. When filtering for actual views you should also be wary of this property.

 

ViewName can be edited after view is created via the class property View.ViewName.

 

If a template has been applied then some of the above will be governed by the template (not able to set them in the view). e.g. cropbox may have been set to a scopebox in the template.

I believe when you are working with a newly created view the .CanHaveShape property will be set to false until you have first made the crop region visible.

 

Visibility and active status can be set via properties of the class:


View.CropBoxVisible = True

View.CropBoxActive =True

 

Do the above first in a subtransaction and then you should be able to apply a shape.

 

ViewTemplates are indicated by built in parameters:

VIEW_TEMPLATE_FOR_SCHEDULE

VIEW_TEMPLATE

 

These can be set by the property of the class e.g. View.ViewTemplateID

 

View templates are objects in the database which share the same class as the views they can be applied to i.e. ViewPlan will have a property ViewPlan.IsTemplate to identify that object as a template not a view. When filtering for actual views you should also be wary of this property.

 

ViewName can be edited after view is created via the class property View.ViewName.

 

If a template has been applied then some of the above will be governed by the template (not able to set them in the view). e.g. cropbox may have been set to a scopebox in the template.

Message 4 of 4
BenoitE&A
in reply to: RPTHOMAS108

BenoitE&A
Collaborator
Collaborator

Thank you very much !!

I am trying these solutions right away !!

I believe the Building Coder could spend a post on this topic, don't you ?

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/
0 Likes

Thank you very much !!

I am trying these solutions right away !!

I believe the Building Coder could spend a post on this topic, don't you ?

Benoit


Benoit FAVRE
CEO of etudes & automates
www.etudesetautomates.com/

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report