5 Replies Latest reply on Jan 27, 2013 11:09 PM by marioweiss

    Add a graphic line via VBScript in DxDesigner

    avjohn

       

      I'm trying to write a VBScript that adds a graphic line to a DxDesigner Schematic and I'm having problems with the code and I've probably forgotten something.  Here's a snippet of the code.

       

       

       

       

       

                      Set CompBlock = ActiveView.Block

                      Set llLine =CompBlock.AddLine(ll, ur)

                      Set Color = llLine.GetObjectColor

                      Color.b = 255

                      Color.g = 255

                      Color.r = 0

                      llLine.SetObjectColor(Color)

                      llLine.LineStyle = VDLINE_DASH

                      llLine.FillStyle = VDFILL_SOLID

       

       

       

      Can anyone tell me what I'm doing wrong?

       

       

        • 1. Re: Add a graphic line via VBScript in DxDesigner
          john_dube

          Hi Tony,

           

          It seems that the Block.AddLine method is broken due to support for enhanced resolution and metric units.

           

          And it was always a pain to use anyway, with the x and y arguments smashed into a single variable.

           

          Someone came up with a great workaround, to use AddArc instead of AddLine.  If the 3 points supplied to the AddArc method are co-linear, you will get a line.  And you can turn it into an arc later by using the stretch command and dragging the center point!

           

          The only drawback is that you need to calculate the mid-point from the start and end point of the line, but that is trivial.  Here is a function that does this:

           

          Function DrawLine(x1,y1,x2,y2)
          Dim midx : midx = (x2 - x1) / 2
          Dim midy : midy = (y2 - y1) / 2
          Set DrawLine = ActiveView.Block.AddArc(x1,y1,midx,midy,x2,y2)
          End Function

           

          John

          • 2. Re: Add a graphic line via VBScript in DxDesigner
            avjohn

            John,

             

            I learned the trick of using AddArc instead of AddLine today from Roger McNeil in Mentor Support.  This works ok.  I think though that if the AddLine method is broke, it either should be fixed (and have it use x,y coordinates for each end of the line instead of mashing the x and y arguments into a single variable) or it should be removed.

             

            Thanks for the help.

             

            Tony

            • 3. Re: Add a graphic line via VBScript in DxDesigner
              marioweiss

              Hi John,

               

              this function works! What can i do to make this line will be visible in pdf-export? I use DxD V9.3.1 and the lines are not visible!

              Here are the properties of lines:

               

               

              DrawLine.LineStyle = VDLINE_SOLID
              DrawLine.Fillstyle= VDFILL_SOLID

               

              DxD_view.JPG

               

              pdf_Exp.JPG

               

              Mario

               

              • 4. Re: Add a graphic line via VBScript in DxDesigner
                john_dube

                Hi Mario,

                 

                In recent releases there is an AddLine2 method that is more straightforward than using an arc.

                 

                However, the arcs should be visible in the PDF file - are you using File -> Export -> PDF?

                 

                John

                • 5. Re: Add a graphic line via VBScript in DxDesigner
                  marioweiss

                  Yes, i create a pdf about "Export PDF" button! Maybe a bug?

                  I use DxDesigner version 9.3.1.

                   

                  Mario