Jump to content

Recommended Posts

Posted

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

Posted

I am using VBA .. Does it Work In vba??

Posted

not sure, Sorry, i dont do vba, lisp only.

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...