ZORANCRO Posted November 11, 2007 Share Posted November 11, 2007 My problem is how to select Acadblock in modelspace and read en attribute in him. I have meny block with attribute, one attribute is text who preseant Z coordinate(Z coordinate = 0,00). I wont to change Z coordinate of Acadblock with val (attribute text).Help me! Brian thank you! I want to select global set of block. Quote Link to comment Share on other sites More sharing options...
bsamc2000 Posted November 20, 2007 Share Posted November 20, 2007 My problem is how to select Acadblock in modelspace and read en attribute in him. I have meny block with attribute, one attribute is text who preseant Z coordinate(Z coordinate = 0,00). I wont to change Z coordinate of Acadblock with val (attribute text).Help me! Are you wanting to select a single block or a global set of blocks? Brian Quote Link to comment Share on other sites More sharing options...
bsamc2000 Posted November 20, 2007 Share Posted November 20, 2007 You can try this. It worked for selecting a single block and then changing the value of the attribute with the tag of "Z". I hope this helps you on your way. Brian Private Sub Change_it() Dim obj As AcadBlockReference Dim inspt As Variant ThisDrawing.Utility.GetEntity obj, inspt, "Select object:" ' Checks if you selected a block. If obj.ObjectName = "AcDbBlockReference" Then ' Check for attributes. If obj.HasAttributes Then Dim AttList As Variant ' Build a list of attributes for the current block. AttList = obj.GetAttributes ' Cycle throught the list of attributes. For I = LBound(AttList) To UBound(AttList) ' Check for the correct attribute tag. If AttList(I).TagString = "Z" Then Dim InputString As String ' Get the new value for the attribute. InputString = ThisDrawing.Utility.GetString(True, "New value for z: ") ' Set the new value for the attribute. AttList(I).TextString = InputString End If Next End If Else MsgBox "You did not select a block." End If End Sub Quote Link to comment Share on other sites More sharing options...
ZORANCRO Posted November 20, 2007 Author Share Posted November 20, 2007 Are you wanting to select a single block or a global set of blocks? Brian Brian thank you! I whant to select global set of block. Zoran Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 21, 2007 Share Posted November 21, 2007 (edited) Here is another version of the same thing pick a block and then update the attributes Public Sub ModifyLabelSTNcoords() ' adds x and y co ords of picked point to labelstn block Dim objENT As AcadEntity Dim pt1 As Variant Dim attribs As Variant On Error Resume Next ThisDrawing.Utility.GetEntity objENT, basepnt, "pick Label stn block : " attribs = objENT.GetAttributes pt1 = ThisDrawing.Utility.GetPoint(, " pick stn point") txtx1 = "E " + CStr(FormatNumber(pt1(0), 3)) TXTY1 = "N " + CStr(FormatNumber(pt1(1), 3)) TXTz1 = "RL " + CStr(FormatNumber(pt1(2), 3)) attribs(2).TextString = txtx1 attribs(2).Update attribs(3).TextString = TXTY1 attribs(3).Update attribs(4).TextString = TXTz1 attribs(4).Update End Sub Edited September 18, 2012 by SLW210 Code Tags!!!!!!!!!! Quote Link to comment Share on other sites More sharing options...
Itc Posted March 21, 2008 Share Posted March 21, 2008 How to use for loop to detcet the block name "Acadblock" and then change the z attribute? Quote Link to comment Share on other sites More sharing options...
moniz Posted September 18, 2012 Share Posted September 18, 2012 You can try this. It worked for selecting a single block and then changing the value of the attribute with the tag of "Z". I hope this helps you on your way. Brian Private Sub Change_it() Dim obj As AcadBlockReference Dim inspt As Variant ThisDrawing.Utility.GetEntity obj, inspt, "Select object:" ' Checks if you selected a block. If obj.ObjectName = "AcDbBlockReference" Then ' Check for attributes. If obj.HasAttributes Then Dim AttList As Variant ' Build a list of attributes for the current block. AttList = obj.GetAttributes ' Cycle throught the list of attributes. For I = LBound(AttList) To UBound(AttList) ' Check for the correct attribute tag. If AttList(I).TagString = "Z" Then Dim InputString As String ' Get the new value for the attribute. InputString = ThisDrawing.Utility.GetString(True, "New value for z: ") ' Set the new value for the attribute. AttList(I).TextString = InputString End If Next End If Else MsgBox "You did not select a block." End If End Sub Can you post the code changes to select a group of blocks? thx Quote Link to comment Share on other sites More sharing options...
BIGAL Posted September 19, 2012 Share Posted September 19, 2012 MONIZ If your happy with pick pick pick then just add loop at start of code above and repeat. Some like For J =50.... next look at code above. A smarter way is also check for object picked nil = exit replace the Else Msgbox with J=50 Selecting multiple blocks can be done depending on how you intend to select "entities" "W" "C" 1 at a time etc Problem with multiple blocks do they all have same Z ? It would be complicated to select a whole lot at once then somehow jump to each one so you can put the correct Z in. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.