biw01
Automotive
- Dec 31, 2011
- 152
Hello Everyone,
I am facing some difficulties in creating a custom model view using NXOpen. I am able to create the view when the application is in Modeling Mode , but if i try to do the same thing if the part is opened in Drafting mode , it throws an error saying the workview is not a model view.
I am using the following code to Switch the application from drafting to modelling mode.
UI.GetUI.MenuBarManager.ApplicationSwitchRequest("UG_APP_MODELING")
Please help!!!
Thanks,
Amitabh
I am facing some difficulties in creating a custom model view using NXOpen. I am able to create the view when the application is in Modeling Mode , but if i try to do the same thing if the part is opened in Drafting mode , it throws an error saying the workview is not a model view.
I am using the following code to Switch the application from drafting to modelling mode.
UI.GetUI.MenuBarManager.ApplicationSwitchRequest("UG_APP_MODELING")
Code:
Public Sub sCreateCustomModellingView(ByVal objPart As Part, ByVal X As Double, ByVal Y As Double, ByVal Z As Double, ByVal Xx As Double, ByVal Xy As Double, ByVal Xz As Double, _
ByVal Yx As Double, ByVal Yy As Double, ByVal Yz As Double, ByVal Zx As Double, _
ByVal Zy As Double, ByVal Zz As Double, ByVal sCustViewName As String, ByVal dScale As Double, _
Optional ByVal sDefaultRefView As String = "FRONT")
Dim objView As View = Nothing
Dim rotMatrix As Matrix3x3 = Nothing
rotMatrix.Xx = Xx
rotMatrix.Xy = Xy
rotMatrix.Xz = Xz
rotMatrix.Yx = Yx
rotMatrix.Yy = Yy
rotMatrix.Yz = Yz
rotMatrix.Zx = Zx
rotMatrix.Zy = Zy
rotMatrix.Zz = Zz
Dim translation As Point3d = New Point3d(X, Y, Z)
If Not objPart.ModelingViews.WorkView Is Nothing Then
objPart.ModelingViews.WorkView.SetRotationTranslationScale(rotMatrix, translation, dScale)
objView = objPart.Views.SaveAs(objPart.ModelingViews.WorkView, sCustViewName, False, False)
Else
For Each objMdVw As ModelingView In objPart.ModelingViews
If objMdVw.Name.ToUpper = sDefaultRefView Then
objMdVw.MakeWork()
objMdVw.SetRotationTranslationScale(rotMatrix, translation, dScale)
objPart.Views.SaveAs(objMdVw, sCustViewName, False, False)
Exit For
End If
Next
End If
End Sub
Please help!!!
Thanks,
Amitabh