Get crop view of a model group in each view

Get crop view of a model group in each view

desaijuhi1910
Participant Participant
337 Views
0 Replies
Message 1 of 1

Get crop view of a model group in each view

desaijuhi1910
Participant
Participant

I have duplicated views equal to the number of model groups I have in my document. What I want is that each model group should be cropped in the view it is present. The name of the views are on the basis of names of model groups so I've used used string.Contains methods to map views with the model groups. My code crops the model groups in alternate number of views,like 1st,3rd and so on. It is due to the increment operator, but if i remove it,it just crops one view. Please help me and let me know what am I missing.

//view_duplicated is the list of all the views i duplicated to test
//mglist is the list of model groups

for (int vmg3 = 0; vmg3 < view_duplicated.Count; vmg3++)
                {
                    
                        for (int vmg2 = 0; vmg2 < mglist.Count; vmg2++)
                    {
                        if (view_duplicated[vmg3].Name.Contains(mglist[vmg2].Name))
                        {
                            bb = mglist[vmg2].get_BoundingBox(view_duplicated[vmg3]);
                            points.Add(bb.Min);
                            points.Add(bb.Max);

                            BoundingBoxXYZ sb = view_duplicated[vmg3].CropBox;
                            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));
                            using (Transaction t = new Transaction(activeDoc, "Crop View By Selection"))
                            {
                                t.Start();
                                //BoundingBoxXYZ sb = view_duplicated[vmg3].CropBox;
                                //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));
                                view_duplicated[vmg3].CropBoxActive = true;
                                view_duplicated[vmg3].CropBox = sb;
                                view_duplicated[vmg3].CropBoxVisible = true;
                                t.Commit();
                                vmg3++;
                                vmg2++;
                            }
                        }
                    }

                }
0 Likes
338 Views
0 Replies
Replies (0)