<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Questions about the system in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12789986#M646</link>
    <description>&lt;P&gt;Hello. I am here trying to make a code where you put in data like width, length, how many and setera. Like in the photo.&lt;/P&gt;&lt;P&gt;And i wanted to&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Change line type and color, but option Set is not allowing me to make any it always glowing red in code.&lt;/P&gt;&lt;P&gt;2. So every cube had it own personal sequenced number but i have no formula for that so i wiil need to change my code.&lt;/P&gt;&lt;P&gt;3. I suppose AcadLine and other acad types are not working or not get registered.&lt;/P&gt;&lt;P&gt;Here is the code because i cannot upload dvb files.&lt;/P&gt;&lt;P&gt;Private Sub DrawRectangle_Click()&lt;/P&gt;&lt;P&gt;Dim starter, pt1, pt2, pt3, pt4, vectorup, bluestart, blueend, redstart, redend, name As Variant&lt;BR /&gt;Dim textObj As Variant&lt;BR /&gt;Dim i, j, cap1, cap2, distanceright, distanceup As Integer&lt;BR /&gt;Dim pi As Double&lt;BR /&gt;Dim blue, red As Variant&lt;/P&gt;&lt;P&gt;UserForm1.Hide&lt;BR /&gt;pi = 3.14&lt;BR /&gt;cap1 = Val(TextBox3.Text)&lt;BR /&gt;cap2 = Val(TextBox4.Text)&lt;/P&gt;&lt;P&gt;distanceright = Val(TextBox1.Text) + Val(TextBox5.Text)&lt;BR /&gt;distanceup = Val(TextBox2.Text) + Val(TextBox5.Text)&lt;BR /&gt;UserForm1.Hide&lt;BR /&gt;starter = ThisDrawing.Utility.GetPoint(, "Pick left starter corner")&lt;BR /&gt;vectorup = starter&lt;BR /&gt;For j = 1 To cap2&lt;BR /&gt;vectorup = ThisDrawing.Utility.PolarPoint(starter, pi / 2, distanceup * (j - 1))&lt;BR /&gt;For i = 1 To cap1&lt;BR /&gt;pt1 = ThisDrawing.Utility.PolarPoint(vectorup, 0, distanceright * (i - 1))&lt;BR /&gt;pt2 = ThisDrawing.Utility.PolarPoint(pt1, 0, Val(TextBox1.Text))&lt;BR /&gt;pt3 = ThisDrawing.Utility.PolarPoint(pt2, pi / 2, Val(TextBox2.Text))&lt;BR /&gt;pt4 = ThisDrawing.Utility.PolarPoint(pt1, pi / 2, Val(TextBox2.Text))&lt;/P&gt;&lt;P&gt;ThisDrawing.ModelSpace.AddLine pt1, pt2&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine pt2, pt3&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine pt3, pt4&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine pt4, pt1&lt;BR /&gt;&lt;BR /&gt;bluestart = ThisDrawing.Utility.PolarPoint(pt1, pi / 4, Sqr((Val(TextBox1.Text) / 4) ^ 2 + (Val(TextBox2.Text) / 10) ^ 2))&lt;BR /&gt;blueend = ThisDrawing.Utility.PolarPoint(bluestart, pi / 2, Val(TextBox2.Text) * 9 / 10 + Val(TextBox5.Text) * 6 / 10)&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine bluestart, blueend&lt;BR /&gt;&lt;BR /&gt;redstart = ThisDrawing.Utility.PolarPoint(pt3, 5 * pi / 4, Sqr((Val(TextBox1.Text) / 4) ^ 2 + (Val(TextBox2.Text) / 10) ^ 2))&lt;BR /&gt;redend = ThisDrawing.Utility.PolarPoint(redstart, pi / 2, Val(TextBox2.Text) / 10 + Val(TextBox5.Text) * 4 / 10)&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine redstart, redend&lt;BR /&gt;&lt;BR /&gt;name = ThisDrawing.Utility.PolarPoint(pt1, pi / 4, Sqr((Val(TextBox1.Text) / 2) ^ 2 + (Val(TextBox2.Text) / 2) ^ 2))&lt;BR /&gt;ThisDrawing.ModelSpace.AddText TextBox8.Text &amp;amp; Val(TextBox9.Text) + i + j - 2, name, Val(TextBox2.Text) / 10&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Next i&lt;BR /&gt;Next j&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
    <pubDate>Wed, 22 May 2024 12:52:21 GMT</pubDate>
    <dc:creator>artur_dobriyan</dc:creator>
    <dc:date>2024-05-22T12:52:21Z</dc:date>
    <item>
      <title>Questions about the system</title>
      <link>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12789986#M646</link>
      <description>&lt;P&gt;Hello. I am here trying to make a code where you put in data like width, length, how many and setera. Like in the photo.&lt;/P&gt;&lt;P&gt;And i wanted to&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Change line type and color, but option Set is not allowing me to make any it always glowing red in code.&lt;/P&gt;&lt;P&gt;2. So every cube had it own personal sequenced number but i have no formula for that so i wiil need to change my code.&lt;/P&gt;&lt;P&gt;3. I suppose AcadLine and other acad types are not working or not get registered.&lt;/P&gt;&lt;P&gt;Here is the code because i cannot upload dvb files.&lt;/P&gt;&lt;P&gt;Private Sub DrawRectangle_Click()&lt;/P&gt;&lt;P&gt;Dim starter, pt1, pt2, pt3, pt4, vectorup, bluestart, blueend, redstart, redend, name As Variant&lt;BR /&gt;Dim textObj As Variant&lt;BR /&gt;Dim i, j, cap1, cap2, distanceright, distanceup As Integer&lt;BR /&gt;Dim pi As Double&lt;BR /&gt;Dim blue, red As Variant&lt;/P&gt;&lt;P&gt;UserForm1.Hide&lt;BR /&gt;pi = 3.14&lt;BR /&gt;cap1 = Val(TextBox3.Text)&lt;BR /&gt;cap2 = Val(TextBox4.Text)&lt;/P&gt;&lt;P&gt;distanceright = Val(TextBox1.Text) + Val(TextBox5.Text)&lt;BR /&gt;distanceup = Val(TextBox2.Text) + Val(TextBox5.Text)&lt;BR /&gt;UserForm1.Hide&lt;BR /&gt;starter = ThisDrawing.Utility.GetPoint(, "Pick left starter corner")&lt;BR /&gt;vectorup = starter&lt;BR /&gt;For j = 1 To cap2&lt;BR /&gt;vectorup = ThisDrawing.Utility.PolarPoint(starter, pi / 2, distanceup * (j - 1))&lt;BR /&gt;For i = 1 To cap1&lt;BR /&gt;pt1 = ThisDrawing.Utility.PolarPoint(vectorup, 0, distanceright * (i - 1))&lt;BR /&gt;pt2 = ThisDrawing.Utility.PolarPoint(pt1, 0, Val(TextBox1.Text))&lt;BR /&gt;pt3 = ThisDrawing.Utility.PolarPoint(pt2, pi / 2, Val(TextBox2.Text))&lt;BR /&gt;pt4 = ThisDrawing.Utility.PolarPoint(pt1, pi / 2, Val(TextBox2.Text))&lt;/P&gt;&lt;P&gt;ThisDrawing.ModelSpace.AddLine pt1, pt2&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine pt2, pt3&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine pt3, pt4&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine pt4, pt1&lt;BR /&gt;&lt;BR /&gt;bluestart = ThisDrawing.Utility.PolarPoint(pt1, pi / 4, Sqr((Val(TextBox1.Text) / 4) ^ 2 + (Val(TextBox2.Text) / 10) ^ 2))&lt;BR /&gt;blueend = ThisDrawing.Utility.PolarPoint(bluestart, pi / 2, Val(TextBox2.Text) * 9 / 10 + Val(TextBox5.Text) * 6 / 10)&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine bluestart, blueend&lt;BR /&gt;&lt;BR /&gt;redstart = ThisDrawing.Utility.PolarPoint(pt3, 5 * pi / 4, Sqr((Val(TextBox1.Text) / 4) ^ 2 + (Val(TextBox2.Text) / 10) ^ 2))&lt;BR /&gt;redend = ThisDrawing.Utility.PolarPoint(redstart, pi / 2, Val(TextBox2.Text) / 10 + Val(TextBox5.Text) * 4 / 10)&lt;BR /&gt;ThisDrawing.ModelSpace.AddLine redstart, redend&lt;BR /&gt;&lt;BR /&gt;name = ThisDrawing.Utility.PolarPoint(pt1, pi / 4, Sqr((Val(TextBox1.Text) / 2) ^ 2 + (Val(TextBox2.Text) / 2) ^ 2))&lt;BR /&gt;ThisDrawing.ModelSpace.AddText TextBox8.Text &amp;amp; Val(TextBox9.Text) + i + j - 2, name, Val(TextBox2.Text) / 10&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Next i&lt;BR /&gt;Next j&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;</description>
      <pubDate>Wed, 22 May 2024 12:52:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12789986#M646</guid>
      <dc:creator>artur_dobriyan</dc:creator>
      <dc:date>2024-05-22T12:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Questions about the system</title>
      <link>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795074#M647</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a little confused about what you want to achieve and your code as using the generic names for your textboxes is not helping understanding the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However I managed to get it to work. If you want to color your Lines you have to do it in two times:&lt;/P&gt;&lt;P&gt;1. creating the line as you did&lt;/P&gt;&lt;P&gt;2. changing its color&lt;/P&gt;&lt;P&gt;For 2. to be doable you need the code to know which line to color, ie. put the line into a named variable.&lt;/P&gt;&lt;P&gt;Also the colors in AutoCAD VBA are objects of type &lt;A href="https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-E5F6DDEB-1856-4D42-B31D-DFB757D74466" target="_blank" rel="noopener"&gt;"TrueColor"&lt;/A&gt;&amp;nbsp;. So you need to use it as indicated in the code example of the help linked.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's suppose you want the "blue" line of your code to be blue. You can do it like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim colorBlue As AcadAcCmColor
Set colorBlue = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." &amp;amp; Left(AcadApplication.Version, 2))
' Defining the RGB values
colorBlue.SetRGB 0, 0, 180


bluestart = ThisDrawing.Utility.PolarPoint(pt1, pi / 4, Sqr((Val(TextBox1.Text) / 4) ^ 2 + (Val(TextBox2.Text) / 10) ^ 2))
blueend = ThisDrawing.Utility.PolarPoint(bluestart, pi / 2, Val(TextBox2.Text) * 9 / 10 + Val(TextBox5.Text) * 6 / 10)
' assigning the line object to a variable
Dim blueLine as AcadLine
Set blueLine = ThisDrawing.ModelSpace.AddLine(bluestart, blueend)
' changing the line color
blueLine.TrueColor = colorBlue&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This should work the same way for the Red line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This answers I suppose your points 1. and 3., but for the 2. I did not understand what you mean. If you want to group your objects "in the code", i suggest you to look for SelectionSets. If you want to group them in the drawing you can create a group as you would do Manually. You can also make a parametric bloc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Finally some hints to better understanding VBA:&lt;/P&gt;&lt;P&gt;Be careful when you write&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim x, y, z As Integer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Only z gets the Integer type, x and y are Variant&lt;/P&gt;&lt;P&gt;You should write&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim x As Integer, y As Integer, z As Integer&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the UserForm editor you can change the name of the TextBoxes so they are easier to understand.&lt;/P&gt;&lt;P&gt;For example, instead of writing&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;cap1 = Val(TextBox3.Text)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;You could write&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;cap1 = Val(BoxCap1.Text)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN&gt;And about getting the TextBox value, i think you could go with&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Val(TextBox.Value)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;A href="https://learn.microsoft.com/en-us/office/vba/api/access.textbox.value" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;As sometimes .Value can differ from .Text property.&lt;/SPAN&gt;&lt;/A&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 24 May 2024 09:57:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795074#M647</guid>
      <dc:creator>saboh12617</dc:creator>
      <dc:date>2024-05-24T09:57:13Z</dc:date>
    </item>
    <item>
      <title>Re: Questions about the system</title>
      <link>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795085#M648</link>
      <description>&lt;P&gt;Here is the whole code indented and commented a little&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Private Sub DrawRectangle_Click()
    ' Variant points &amp;lt;=&amp;gt; Array(x, y, z)
    Dim starter, pt1, pt2, pt3, pt4, vectorup, bluestart, blueend, redstart, redend, name

    ' not used: Dim textObj

    Dim colorBlue As AcadAcCmColor
    Set colorBlue = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." &amp;amp; Left(AcadApplication.Version, 2))
    ' Defining the blue color RGB values
    colorBlue.SetRGB 0, 180, 0
    Dim colorRed As AcadAcCmColor
    Set colorRed = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor." &amp;amp; Left(AcadApplication.Version, 2))
    ' Defining the red color RGB values
    colorRed.SetRGB 255, 0, 0

    ' hiding the userform
    UserForm1.Hide

    Dim pi As Double
    pi = 3.14

    Dim cap1 As Integer, cap2 As Integer
    cap1 = Val(TextBox3.Text)
    cap2 = Val(TextBox4.Text)
    
    Dim distanceright As Integer, distanceup As Integer
    distanceright = Val(TextBox1.Text) + Val(TextBox5.Text)
    distanceup = Val(TextBox2.Text) + Val(TextBox5.Text)

    ' you already hid the userform before: UserForm1.Hide

    starter = ThisDrawing.Utility.GetPoint(, "Pick left starter corner")
    vectorup = starter

    Dim i As Integer, j As Integer
    For j = 1 To cap2
        vectorup = ThisDrawing.Utility.PolarPoint(starter, pi / 2, distanceup * (j - 1))
        For i = 1 To cap1
            pt1 = ThisDrawing.Utility.PolarPoint(vectorup, 0, distanceright * (i - 1))
            pt2 = ThisDrawing.Utility.PolarPoint(pt1, 0, Val(TextBox1.Text))
            pt3 = ThisDrawing.Utility.PolarPoint(pt2, pi / 2, Val(TextBox2.Text))
            pt4 = ThisDrawing.Utility.PolarPoint(pt1, pi / 2, Val(TextBox2.Text))
            
            ThisDrawing.ModelSpace.AddLine pt1, pt2
            ThisDrawing.ModelSpace.AddLine pt2, pt3
            ThisDrawing.ModelSpace.AddLine pt3, pt4
            ThisDrawing.ModelSpace.AddLine pt4, pt1
            
            
            bluestart = ThisDrawing.Utility.PolarPoint(pt1, pi / 4, Sqr((Val(TextBox1.Text) / 4) ^ 2 + (Val(TextBox2.Text) / 10) ^ 2))
            blueend = ThisDrawing.Utility.PolarPoint(bluestart, pi / 2, Val(TextBox2.Text) * 9 / 10 + Val(TextBox5.Text) * 6 / 10)
            ' assigning the line object to a variable
            Dim blueLine as AcadLine
            Set blueLine = ThisDrawing.ModelSpace.AddLine(bluestart, blueend)
            ' changing the line color
            blueLine.TrueColor = colorBlue

            redstart = ThisDrawing.Utility.PolarPoint(pt3, 5 * pi / 4, Sqr((Val(TextBox1.Text) / 4) ^ 2 + (Val(TextBox2.Text) / 10) ^ 2))
            redend = ThisDrawing.Utility.PolarPoint(redstart, pi / 2, Val(TextBox2.Text) / 10 + Val(TextBox5.Text) * 4 / 10)
            Dim redLine as AcadLine
            Set redLine = ThisDrawing.ModelSpace.AddLine(redstart, redend)
            ' changing the line color
            blueLine.TrueColor = colorRed

            name = ThisDrawing.Utility.PolarPoint(pt1, pi / 4, Sqr((Val(TextBox1.Text) / 2) ^ 2 + (Val(TextBox2.Text) / 2) ^ 2))
            ThisDrawing.ModelSpace.AddText TextBox8.Text &amp;amp; Val(TextBox9.Text) + i + j - 2, name, Val(TextBox2.Text) / 10
            
        Next i
    Next j
    
End Sub&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 May 2024 10:05:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795085#M648</guid>
      <dc:creator>saboh12617</dc:creator>
      <dc:date>2024-05-24T10:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: Questions about the system</title>
      <link>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795093#M649</link>
      <description>&lt;P&gt;Many thanks for your answer.&lt;/P&gt;&lt;P&gt;I have managed to make Line color and type work yesterday. Didnt knew that Set function requires to use () in the value section.&lt;/P&gt;&lt;P&gt;Havent known that you are required to write every variable as individual integer, fought its like in the C or python where it works for every in the line.&lt;/P&gt;&lt;P&gt;What about textboxes i knew i can do it, but fought it would be easier for me because i often misspritn text and after that finding the error would be a nightmare.&lt;/P&gt;&lt;P&gt;What about 2 question. I just made n=n+1 formula in the for so it always gets a new number for the box.&lt;/P&gt;&lt;P&gt;Again many thanks for your answer it improved me a little bit.&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 10:08:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795093#M649</guid>
      <dc:creator>artur_dobriyan</dc:creator>
      <dc:date>2024-05-24T10:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: Questions about the system</title>
      <link>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795138#M650</link>
      <description>&lt;P&gt;Yes, indeed VBA syntax is very tricky and confusing.&lt;/P&gt;&lt;P&gt;Generally speaking when you call a function without using its return value you should not put the parenthesis, as you did for&lt;/P&gt;&lt;P&gt;ThisDrawing.ModelSpace.AddLine pt1, pt2&lt;/P&gt;&lt;P&gt;When you apply its return value to a variable, then you need the parenthesis. As you did for&lt;/P&gt;&lt;P&gt;pt2 = acaddoc.Utility.PolarPoint(pt1, 0, TextBox)&lt;/P&gt;&lt;P&gt;And yes, the Dim statement is just different (many people get confused about it).&lt;/P&gt;&lt;P&gt;Glad you made it work!&lt;/P&gt;</description>
      <pubDate>Fri, 24 May 2024 10:28:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/questions-about-the-system/m-p/12795138#M650</guid>
      <dc:creator>saboh12617</dc:creator>
      <dc:date>2024-05-24T10:28:43Z</dc:date>
    </item>
  </channel>
</rss>

