Change scale and position of drawing view

Change scale and position of drawing view

adhil.pa.789
Contributor Contributor
305 Views
2 Replies
Message 1 of 3

Change scale and position of drawing view

adhil.pa.789
Contributor
Contributor

Hi,

Changing position and scale is not working for me.  Anyone know this?

Sub IdwPart()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

strLocation = ThisApplication.FileOptions.TemplatesPath
Set oDrgDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, strLocation & "A3.idw")

Dim oSheet As Sheet
Set oSheet = oDrgDoc.Sheets.Item(1)

Dim oPoint1, oPoint2 As Point2d
Set oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
Set oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(10, -5)
    
Dim oBaseView, top As DrawingView
Set oBaseView = oSheet.DrawingViews.AddBaseView(oDoc, oPoint1, 1, kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
Set top = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)


'scale value


Dim  scle As Double
    
scle = (29.7 - 17) / (oBaseView.Height + top.Height)
Dim a, s As String
a = ":1"
s = scle & a
  

Select Case scle
 
  Case Is > 1.5
    oSheet.Size = kA4DrawingSheetSize
   oBaseView.ScaleString = s
   oBaseView.Position.X = 15
   
  Case 0.4 To 1.5
  oSheet.Size = kA3DrawingSheetSize
    oBaseView.ScaleString = s
   oBaseView.Position.X = 21
        
  End Select

End Sub
0 Likes
306 Views
2 Replies
Replies (2)
Message 2 of 3

Andrii_Humeniuk
Advisor
Advisor

Hi @adhil.pa.789 . Changing the scale and position worked for me only when I took them outside the "Select Case", maybe your "scle" parameter does not fall within the selection.

Andrii Humeniuk - CAD Coordinator, Autodesk Certified Instructor

LinkedIn | My free Inventor Addin | My Repositories

Did you find this reply helpful ? If so please use the Accept as Solution/Like.

EESignature

0 Likes
Message 3 of 3

adhil.pa.789
Contributor
Contributor
Sub IdwPart()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument

strLocation = ThisApplication.FileOptions.TemplatesPath
Set oDrgDoc = ThisApplication.Documents.Add(kDrawingDocumentObject, strLocation & "A3.idw")

Dim oSheet As Sheet
Set oSheet = oDrgDoc.Sheets.Item(1)


Dim oPoint1, oPoint2 As Point2d
Set oPoint1 = ThisApplication.TransientGeometry.CreatePoint2d(10, 10)
Set oPoint2 = ThisApplication.TransientGeometry.CreatePoint2d(10, -5)
    
Dim oBaseView, top As DrawingView
Set oBaseView = oSheet.DrawingViews.AddBaseView(oDoc, oPoint1, 1, kFrontViewOrientation, DrawingViewStyleEnum.kHiddenLineDrawingViewStyle)
Set top = oSheet.DrawingViews.AddProjectedView(oBaseView, oPoint2, DrawingViewStyleEnum.kFromBaseDrawingViewStyle)


'scale value


Dim d1, d2, d3, scle, s1, s2, s3 As Double
    

scle = (29.7 - 17) / (oBaseView.Height + top.Height)
Dim a, s As String
a = ":1"
s = scle & a

Dim oCoords(0 To 1) As Double
Dim pnt As Point2d
Dim oView1 As DrawingView
Set oView1 = oSheet.DrawingViews.Item(1)


Select Case scle
 
  Case Is > 1.5
    oSheet.Size = kA4DrawingSheetSize
    oBaseView.ScaleString = s
     oCoords(0) = 15
     oCoords(1) = 15
    Set pnt = ThisApplication.TransientGeometry.CreatePoint2d(oCoords(0), oCoords(1))
    oView1.Position = pnt

  Case 0.4 To 1.5
    oSheet.Size = kA3DrawingSheetSize
    oBaseView.ScaleString = s
     oCoords(0) = 21
     oCoords(1) = 15
    
     Set pnt = ThisApplication.TransientGeometry.CreatePoint2d(oCoords(0), oCoords(1))
    oView1.Position = pnt
 
     
  End Select
End Sub

 

Thanks for reply @Andrii_Humeniuk 

 

I got it

0 Likes