<?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 Re: block attribute text alignment in VBA Forum</title>
    <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12311774#M1220</link>
    <description>&lt;P&gt;Please don't post images of code. Its too hard to read and impossible to test without retyping. Please use a code window&amp;nbsp; using the &amp;lt;/&amp;gt; button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to Help, the Left alignment uses the InsertionPoint of the attribute/text. So all alignment options are relative to the text, not the container. Unless there is a bug in pyautocad.&lt;/P&gt;</description>
    <pubDate>Tue, 17 Oct 2023 14:53:24 GMT</pubDate>
    <dc:creator>Ed__Jobe</dc:creator>
    <dc:date>2023-10-17T14:53:24Z</dc:date>
    <item>
      <title>block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12311698#M1219</link>
      <description>&lt;P&gt;I realize my code is in python using pyautocad, but maybe the fundamental problem could be solved here, and I could implement it within my code.&amp;nbsp; I am creating a Bill of Materials table from an excel sheet.&amp;nbsp; I have created blocks with attributes referring to the column names within the table.&amp;nbsp; Whenever I set the ".Alignment" property (line 65) to align "Description" within its area, it seems to become aligned according to the insertion point of the block i.e. (0, 0, 0) currently I have hard coded the aDouble within the ".AddAttribute" method to center each attribute text.&amp;nbsp; I apologize in advance if this is in the wrong group.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 14:20:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12311698#M1219</guid>
      <dc:creator>joshua_haleyFS9U6</dc:creator>
      <dc:date>2023-10-17T14:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12311774#M1220</link>
      <description>&lt;P&gt;Please don't post images of code. Its too hard to read and impossible to test without retyping. Please use a code window&amp;nbsp; using the &amp;lt;/&amp;gt; button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to Help, the Left alignment uses the InsertionPoint of the attribute/text. So all alignment options are relative to the text, not the container. Unless there is a bug in pyautocad.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Oct 2023 14:53:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12311774#M1220</guid>
      <dc:creator>Ed__Jobe</dc:creator>
      <dc:date>2023-10-17T14:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12312837#M1221</link>
      <description>Maybe use acAttributeModeLockPosition = 16&lt;BR /&gt;&lt;A href="https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-53417B1F-C6F1-4818-AD43-8C5F81E36BCA" target="_blank"&gt;https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-53417B1F-C6F1-4818-AD43-8C5F81E36BCA&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I’m wondering why you’re not using a table?&lt;BR /&gt;btw If you’re coding in Python, you might want to have a look here&lt;BR /&gt;&lt;A href="https://github.com/CEXT-Dan/PyRx" target="_blank"&gt;https://github.com/CEXT-Dan/PyRx&lt;/A&gt;&lt;BR /&gt;and&lt;BR /&gt;&lt;A href="https://www.theswamp.org/index.php?board=76.0" target="_blank"&gt;https://www.theswamp.org/index.php?board=76.0&lt;/A&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Oct 2023 23:14:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12312837#M1221</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2023-10-17T23:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12314710#M1222</link>
      <description>&lt;P&gt;I'm building a bill of materials table from an excel sheet.&amp;nbsp; Right now, I'm hard coding the insertion points (Line 28-32) for the attribute text in order to center them within their respective spaces.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from pyautocad import ACAD, Autocad, APoint, aDouble

acad = Autocad(create_if_not_exists=True)

ip = APoint(0, 0, 0)

yStack = 0.0

blockName = "BOM Header"
b1 = acad.doc.Blocks.Add(ip, blockName)
p1 = b1.AddPolyline(aDouble(0,0,0, 5.3382,0,0, 5.3382,.1250,0, 0,.1250,0, 0,0,0))
a1 = b1.AddAttribute(.0625, 0, "BOM", aDouble(2.3, .03125, 0), "BOM", "BILL OF MATERIAL")

blockRef = acad.model.InsertBlock(APoint(10, 10 + yStack, 0), blockName, 1, 1, 1, 0)

yStack = -.1250
row = 2

blockName = "BOM Header 2"
b1 = acad.doc.Blocks.Add(ip, blockName)
p1 = b1.AddPolyline(aDouble(0,0,0, 5.3382,0,0, 5.3382,.1250,0, 0,.1250,0, 0,0,0))

l1 = b1.AddLine(APoint(.3139, 0, 0), APoint(.3139, .1250, 0))
l2 = b1.AddLine(APoint(.5970, 0, 0), APoint(.5970, .1250, 0))
l3 = b1.AddLine(APoint(2.9096, 0, 0), APoint(2.9096, .1250, 0))
l4 = b1.AddLine(APoint(4.3024, 0, 0), APoint(4.3024, .1250, 0))

a1 = b1.AddAttribute(.0625, 0, "ITEM", aDouble(.05, .03125, 0), "ITEM", "ITEM")
a2 = b1.AddAttribute(.0625, 0, "QTY", aDouble(.3639, .03125, 0), "QTY", "QTY")
a3 = b1.AddAttribute(.0625, 0, "DESCRIPTION", aDouble(1.45, .03125, 0), "DESCRIPTION", "DESCRIPTION")
a4 = b1.AddAttribute(.0625, 0, "PART", aDouble(3.3, .03125, 0), "PART", "PART NUMBER")
a5 = b1.AddAttribute(.0625, 0, "MANUFACTURER", aDouble(4.45, .03125, 0), "MANUFACTURER", "MANUFACTURER")

blockRef = acad.model.InsertBlock(APoint(10, 10 + yStack, 0), blockName, 1, 1, 1, 0)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="joshua_haleyFS9U6_0-1697642129109.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1280787iD0D6784548167885/image-size/medium?v=v2&amp;amp;px=400" role="button" title="joshua_haleyFS9U6_0-1697642129109.png" alt="joshua_haleyFS9U6_0-1697642129109.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was wondering if there was a way to set each columns text to a middle alignment so it could center any text dynamically and not reference the fixed insertion point. I've tried to use "a3.Alignment = 1" in reference the acAlignment enum values but it seems to align it to the block insertion point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="joshua_haleyFS9U6_1-1697643284639.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1280803iB2F51F513A21C086/image-size/medium?v=v2&amp;amp;px=400" role="button" title="joshua_haleyFS9U6_1-1697643284639.png" alt="joshua_haleyFS9U6_1-1697643284639.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 15:37:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12314710#M1222</guid>
      <dc:creator>joshua_haleyFS9U6</dc:creator>
      <dc:date>2023-10-18T15:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12314720#M1223</link>
      <description>&lt;P&gt;I have been told these need to be attributed blocks.&amp;nbsp; It does seem a table would be more appropriate.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 15:42:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12314720#M1223</guid>
      <dc:creator>joshua_haleyFS9U6</dc:creator>
      <dc:date>2023-10-18T15:42:45Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12314794#M1224</link>
      <description>&lt;P&gt;This may not suit your business process, but here it goes anyway.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data source is an Excel sheet, I'd always try create a AutoCAD Table (only table itself: title row, columns) first, then use DataLink to link the table from the sheet. Easy and fast. Any data change in the sheet would be updated to the table automatically. No programming is required (and yes, code with .NET API can be used to manipulate Datalink at runtime, if needed).&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 16:06:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12314794#M1224</guid>
      <dc:creator>Norman_Yuan</dc:creator>
      <dc:date>2023-10-18T16:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12315590#M1225</link>
      <description>&lt;P&gt;It seems you need to set the TextAlignmentPoint&lt;/P&gt;&lt;P&gt;Not sure if this is the behavior you want, but try&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;      a3.Alignment = Ax.constants.acAlignmentCenter
      a3.TextAlignmentPoint = (1.45, .03125,0)&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 18 Oct 2023 22:08:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12315590#M1225</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2023-10-18T22:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12315620#M1226</link>
      <description>&lt;P&gt;Also, if you wanted to try a Table,&amp;nbsp; openpyxl is amazing,&lt;/P&gt;&lt;P&gt;note I’m using PyRx, but this sample is activex, so it should be easy enough to recreate with pyautocad&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import PyRx as Rx
import traceback

#ActiveX
import AxApp24 as Ax
import openpyxl as Ex

def PyRxCmd_doit():
    try:
        axApp = Ax.getApp()
        axDoc = axApp.ActiveDocument
        
        wb = Ex.load_workbook('E:\\ItsAlive.xlsx')
        ws = wb.active

        pos = axDoc.Utility.GetPoint("\nPick a point: ")

        axTable = axDoc.ModelSpace.AddTable(
            pos, ws.max_row + 2, ws.max_column, 10, 40)
        
        for nrow in range(2,ws.max_row + 2):
            for ncol in range(ws.max_column):
                axTable.SetTextString(
                    nrow,ncol,1,ws.cell(
                        row=nrow, column=ncol+1).value)
                
    except Exception as err:
        traceback.print_exception(err)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2023 22:35:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12315620#M1226</guid>
      <dc:creator>daniel_cadext</dc:creator>
      <dc:date>2023-10-18T22:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12319602#M1227</link>
      <description>&lt;P&gt;For anyone referencing this post, I solved my Issue. In order to change the Text Alignment Point you must first change the attribute reference Alignment Point.&amp;nbsp; You cannot modify the Text Alignment Point until you do this.&amp;nbsp; To set the attribute text alignment point to middle center do this -&amp;nbsp;&lt;/P&gt;&lt;P&gt;(python using pyautocad)&lt;/P&gt;&lt;P&gt;attributeReference.Alignment = 10&lt;/P&gt;&lt;P&gt;attributeReference.TextAlignmentPoint = aDouble(x, y, z coordinates within block to align text)&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 13:37:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12319602#M1227</guid>
      <dc:creator>joshua_haleyFS9U6</dc:creator>
      <dc:date>2023-10-20T13:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: block attribute text alignment</title>
      <link>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12319611#M1228</link>
      <description>&lt;P&gt;Saw this solution after I posted mine lol.&amp;nbsp; I must have overlooked the remarks in the docs about having to change the alignment from left or aligned to anything else in order to be able to set the Text Alignment Point. Thank you for your time!&lt;/P&gt;</description>
      <pubDate>Fri, 20 Oct 2023 13:35:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/vba-forum/block-attribute-text-alignment/m-p/12319611#M1228</guid>
      <dc:creator>joshua_haleyFS9U6</dc:creator>
      <dc:date>2023-10-20T13:35:27Z</dc:date>
    </item>
  </channel>
</rss>

