Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
in reply to: Owner2229

Hi Mike!

 

Thank you very much for the answer. I adjusted your code a little bit so it will work for selected views only. I hope this might be useful for others.

 

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then Exit Sub

Dim oView As DrawingView
Dim oSSet As SelectSet = ThisDoc.Document.SelectSet
If oSSet.count = 0 Then
	MessageBox.Show("Select view(s)", "Attention!")
Exit Sub
End If

For Each oSheet As Sheet In oDoc.Sheets
     If oSheet.DrawingViews.Count = 0 Then Continue For
     For Each oView In oSSet
          Dim oModel As Document = oView.ReferencedDocumentDescriptor.ReferencedDocument
          If oModel.DocumentSubType.DocumentSubTypeID <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then Continue For
          Dim oOptions As NameValueMap = ThisApplication.TransientObjects.CreateNameValueMap
          oOptions.Add("SheetMetalFoldedModel", False)
          Dim oPoint As Point2D = oView.Position
          Dim oViewStyle As DrawingViewStyleEnum = oView.ViewStyle
          Dim oScale As Double = oView.Scale
          Dim oOri As ViewOrientationTypeEnum = ViewOrientationTypeEnum.kDefaultViewOrientation
          oSheet.DrawingViews.AddBaseView(oModel, oPoint, oScale, oOri, oViewStyle, , , oOptions)
          oView.Delete()
     Next
Next