title: CATIA VBA - Get scale ratio of front view in drawing
body: <p>could anyone help me with the problem - I am creating a program to automatically fill in the title block in drawing. Unable to get the decimal value of the Scale of front view, I also can't get the used material of the given part + weight.
  I still have the following source code. Thank you for all the answers!</p>
  <pre><code>    Private Sub CommandButton1_Click()
     
  Dim DrwDocument As DrawingDocument
  Set DrwDocument = CATIA.ActiveDocument
  
  
      Set DrwSheets = DrwDocument.Sheets
      Set Selection = DrwDocument.Selection
      Set DrwSheet = DrwSheets.ActiveSheet
      Set DrwView = DrwSheet.Views.ActiveView
      Set DrwTexts = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.ActiveView.Texts
      Dim oProduct As Product
      Set oProduct = DrwView.GenerativeBehavior.Document
    
      Dim parameters4 As Parameters
      Set parameters4 = DrwDocument.Parameters
  
      Dim realParam4 As Parameter
      Set realParam4 = parameters4.Item(&quot;Sheet.1\ViewMakeUp.3\Scale&quot;)
      
      Dim parametersX As Parameters
      Set parametersX = DrwDocument.Parameters
      Dim realXdir As Parameter
      Set realXdir = parametersX.Item(&quot;Sheet.1\ViewMakeUp.3\X&quot;)
      
      Dim parametersY As Parameters
      Set parametersY = DrwDocument.Parameters
      Dim realYdir As Parameter
      Set realYdir = parametersY.Item(&quot;Sheet.1\ViewMakeUp.3\Y&quot;)
   
      
      DrwView.Activate
      
          If tbProjekt = &quot;&quot; Then
          MsgBox (&quot;Nevyplnené pole PROJEKT!&quot;)
          Else
          Set Projekt = DrwTexts.Add(tbProjekt.Text, (288 - realXdir.ValueAsString), (45.5 - realYdir.ValueAsString))
          Projekt.AnchorPosition = catMiddleLeft
          Projekt.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          Projekt.SetFontSize 0, 0, 3
          End If
          
          Set PocetKs = DrwTexts.Add(tbPocetKs.Text + &quot;x&quot;, (36 - realXdir.ValueAsString), (78 - realYdir.ValueAsString))
          PocetKs.AnchorPosition = catMiddleLeft
          PocetKs.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          PocetKs.SetFontSize 0, 0, 3
          
              If OptionZrk = True Then
                  Set PocetKsZrk = DrwTexts.Add(tbPocetKs.Text + &quot;x&quot;, (36 - realXdir.ValueAsString), (68 - realYdir.ValueAsString))
                  PocetKsZrk.AnchorPosition = catMiddleLeft
                  PocetKsZrk.SetFontName 0, 0, &quot;Monospac821 BT&quot;
                  PocetKsZrk.SetFontSize 0, 0, 3
                  
                  Set ZrkText = DrwTexts.Add(&quot;Zrkadlový&quot;, (103 - realXdir.ValueAsString), (68 - realYdir.ValueAsString))
                  ZrkText.AnchorPosition = catMiddleLeft
                  ZrkText.SetFontName 0, 0, &quot;Arial (TrueType)&quot;
                  ZrkText.SetFontSize 0, 0, 4
                  
              End If
       
          Set Material = DrwTexts.Add(cbMaterial.Text, (288 - realXdir.ValueAsString), (37.5 - realYdir.ValueAsString))
          Material.AnchorPosition = catMiddleLeft
          Material.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          Material.SetFontSize 0, 0, 3
          
          Set Mierka = DrwTexts.Add(realParam4.ValueAsString, (238 - realXdir.ValueAsString), (40 - realYdir.ValueAsString))
          Mierka.AnchorPosition = catMiddleLeft
          Mierka.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          Mierka.SetFontSize 0, 0, 3
          
          Set DatumUpravy = DrwTexts.Add(tbDatum.Text, (355 - realXdir.ValueAsString), (38 - realYdir.ValueAsString))
          DatumUpravy.AnchorPosition = catMiddleLeft
          DatumUpravy.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          DatumUpravy.SetFontSize 0, 0, 3
          
          Set CisloDielu = DrwTexts.Add(tbCisloDielu.Text, (314 - realXdir.ValueAsString), (14.5 - realYdir.ValueAsString))
          CisloDielu.AnchorPosition = catMiddleLeft
          CisloDielu.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          CisloDielu.SetFontSize 0, 0, 4
          
          Set NazovDielu = DrwTexts.Add(tbNazovDielu.Text, (321 - realXdir.ValueAsString), (26 - realYdir.ValueAsString))
          NazovDielu.AnchorPosition = catMiddleLeft
          NazovDielu.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          NazovDielu.SetFontSize 0, 0, 4
          
          Set Pozicia = DrwTexts.Add(tbPozicia.Text, (388 - realXdir.ValueAsString), (26 - realYdir.ValueAsString))
          Pozicia.AnchorPosition = catMiddleLeft
          Pozicia.SetFontName 0, 0, &quot;Monospac821 BT&quot;
          Pozicia.SetFontSize 0, 0, 5
  
          
  End Property
  
  
  Private Sub UserForm_Initialize()
      Dim DrwDocument As DrawingDocument
      Set DrwDocument = CATIA.ActiveDocument
  
  
      Set DrwSheets = DrwDocument.Sheets
      Set Selection = DrwDocument.Selection
      Set DrwSheet = DrwSheets.ActiveSheet
      Set DrwView = DrwSheet.Views.ActiveView
      Set DrwTexts = CATIA.ActiveDocument.Sheets.ActiveSheet.Views.ActiveView.Texts
      Dim oProduct As Product
      Set oProduct = DrwView.GenerativeBehavior.Document
      
      Dim parameters4 As Parameters
      Set parameters4 = DrwDocument.Parameters
  
      Dim realParam4 As Parameter
      Set realParam4 = parameters4.Item(&quot;Sheet.1\ViewMakeUp.3\Scale&quot;)
      Dim datum As Date
      datum = Now()
      tbDatum.Text = Format(datum, &quot;dd.mm.yyyy&quot;)
         
      
     cbMaterial.AddItem &quot;S355J2G3&quot;
     cbMaterial.AddItem &quot;X5CrNi18-10&quot;
     cbMaterial.AddItem &quot;PE1000-green&quot;
     
      tbMierka.Text = realParam4.ValueAsString
      tbCisloDielu = (oProduct.PartNumber)
      tbNazovDielu = (oProduct.Nomenclature)
      Dim cProjektu As String
      cProjektu = tbCisloDielu.value
      tbProjekt.Text = Left(cProjektu, 6)
      Dim parametersX As Parameters
      Set parametersX = DrwDocument.Parameters
      Dim realXdir As Parameter
      Set realXdir = parametersX.Item(&quot;Sheet.1\ViewMakeUp.3\X&quot;)
      
      Dim parametersY As Parameters
      Set parametersY = DrwDocument.Parameters
      Dim realYdir As Parameter
      Set realYdir = parametersY.Item(&quot;Sheet.1\ViewMakeUp.3\Y&quot;)
      tbPriecinok.Text = &quot;D:\3D sro\Zákazky\2022\&quot;
  
  End Sub
  </code></pre>