AnsweredAssumed Answered

Workaround For Setting ModelToViewTransform

Question asked by John Alexander on Mar 3, 2016


I'm trying to set up "context" views of a model's "primary" views that can be cropped. The only way that my team has been able to achieve this in a drawing is to create duplicates of each view, change their configuration to a version that shows the context, and align them with their respective views.


For instance, if there is an assembly and a sub-assembly that needs to be drawn. The subassembly will have three primary views and three context views overlaid on top of them. The primary views will show only the sub-assembly while the context views will show the entire assembly (giving context to the sub-assembly in the greater scheme). This is very tedious to do manually.


I'm aware of the existence of Alternate Position View but these views must also be cropped so that the focus is on the primary view. With my current version of Solidworks (2012), alternate position views do not successfully crop (they appear to crop, but when you print, they show the whole damn thing). Additionally, using a single view with the context portion of the model set to a lighter line font is not a solution because it doesn't produce the required visual effect (if features of the context part are in front of the primary model, they will obscure the primary model's features - this isn't acceptable). I am also aware that the Display Style can be set to ShadedWithEdges to achieve the desired effect but this is also unacceptable for different reasons.


Current Problem:

I'm working on a macro to insert the context views on top of the primary views. The problem that I am having has to do with emulating the ModelToViewTransform of the existing primary views. If I insert a context view and align it with its respective primary view on the drawing, I cannot find a way of setting the ModelToViewTransform so that the context view agrees with the primary view. ModelToViewTransform is a get-only property that can only be manipulated indirectly.


The only way that I have discovered to manipulate the view's ModelToViewTranform has been through the CreateDrawViewFromModelView3. In this way, I can set the ModelView for a context view so that it agrees with the primary view. The problem arises when primary views are encountered that do not have a ModelView assigned (GetOrientationName returns an empty string). I'm not sure of the terminology, but these views were created by either copying an existing view or by creating Relative Views. These views should therefore have a parent view which can be accessed using GetBaseView.


My proposed solution is to recursively call GetBaseView until a view is reached that returns a non-empty string from GetOrientationName. I can then create a context view with this name and then perform CreateRelativeView in the correct sequence to reproduce the original primary view. Although this process is complicated, I'm used to having to do backflips in order to get what I want out of the Solidworks API. The most tedious part will be figuring the correct sequence of CreateRelativeView to perform. However, before I jump, I wanted to ask the community if there is an easier or cleaner solution to the problem.