amakke Posted January 5, 2010 Posted January 5, 2010 Hi, I have an autocad drawing with the same block repeated many times. I am trying to select each of these blocks and edit them thru my macro. I need to at all times to know wich block I am modiying. Is there a way to select a block through location?? Currently I am looping through all blocks in the drawing then filtering these blocks by BlockName. I still need to filter the blocks with same block names ( i dont care how) with using the mouse to select it Thanks in advance Quote
amakke Posted January 5, 2010 Author Posted January 5, 2010 I am using VBA .. Does it Work In vba?? Quote
wizman Posted January 5, 2010 Posted January 5, 2010 not sure, Sorry, i dont do vba, lisp only. Quote
BIGAL Posted January 7, 2010 Posted January 7, 2010 You can do it in VBA pretty easy prefer it for attribute changes. Dim SS As AcadSelectionSet Dim objENT As AcadEntity Dim Count, Cntr As Integer Dim Newpitname As String Dim pitname As String Dim FilterDXFCode(0) As Integer Dim FilterDXFVal(0) As Variant Dim PitNameSelect As AcadObject Dim basepnt, pt1, pt2, pt3 As Variant Dim attribs As Variant block_name = myblockname ' put your block here FilterDXFCode(0) = 0 FilterDXFVal(0) = "INSERT" 'FilterDXFCode(1) = 2 'FilterDXFVal(1) = "SCHEDTEXT" Set SS = ThisDrawing.SelectionSets.Add("pit1sel") SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal For Cntr = 0 To SS.Count - 1 If SS.Item(Cntr).Name = BLOCK_NAME Then ' do your bit here zoom centre etc attribs = SS.Item(Cntr).GetAttribute pt1 = ThisDrawing.Utility.GetPoint(, " pick first point") txtx1 = CStr(FormatNumber(pt1(0), 3)) TXTY1 = CStr(FormatNumber(pt1(1), 3)) attribs(1).TextString = txtx1 attribs(2).TextString = TXTY1 attribs(1).Update attribs(2).Update ' ThisDrawing.Application.Update Else: End If Next Cntr ThisDrawing.SelectionSets.Item("pit1sel").Delete Hope this helps Quote
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.