Mark,
That does make sense but the code still falls over at this line,
ss.Select(AutoCAD.AcSelect.acSelectionSetAll, , , fType, fData)
Before it even gets to,
Change_Attributes(ss.item(i), "JOB1", "we changed this value")
This is still the same exception
An unhandled exception of type 'System.NullReferenceException' occurred in
_testing application.exe
Additional information: Object reference not set to an instance of an
object.
"Mark Propst" wrote in message
news:8B481613075A85CCD0FB320C00DE95BE@in.WebX.maYIadrTaRb...
> Russ,
> You're passing a selection set object to a function that expects a block
> reference object.
> or am I missing something?
> > Dim ss As AcadSelectionSet
> ...
> > Private Sub Change_Attributes(ByVal oBlk As AcadBlockReference,
ByVal
> ...
> > If ss.Count > 0 Then
> > Change_Attributes(ss, "JOB1", "we changed this
> value")<------is this right?
> > End If
>
> what about something like...
> If ss.Count > 0 Then
> dim i as long
> For i = 0 to ss.count - 1
> Change_Attributes(ss.item(i), "JOB1", "we changed this
> value")
> Next
>
> any help?
> Mark
>
> "Russ Green" wrote in message
> news:596E2F17B0D8AF1D33AD049B0AC49111@in.WebX.maYIadrTaRb...
> > Thanks for the reply. Looks like lots of useful code on your site..
> >
> > So this is the code so far. But the following exception occurs..
> >
> > Line of code:
> > ss.Select(AutoCAD.AcSelect.acSelectionSetAll, , , fType, fData)
> >
> > Exception:
> > An unhandled exception of type 'System.NullReferenceException' occurred
in
> > _testing application.exe
> >
> > Additional information: Object reference not set to an instance of an
> > object.
> >
> >
> > Code:
> >
> > Private Sub btnEditValue_Click(ByVal sender As System.Object, ByVal
e
> As
> > System.EventArgs) Handles btnEditValue.Click
> > Dim CreateSelectionSet As Object
> > Dim ss As AcadSelectionSet
> > Dim fType As Object
> > Dim fData As Object
> >
> > ss = CreateSelectionSet
> >
> > BuildFilter(fType, fData, 0, "INSERT", 2, "TITLEBLOCK_MAIN")
> > ss.Select(AutoCAD.AcSelect.acSelectionSetAll, , , fType, fData)
> >
> > If ss.Count > 0 Then
> > Change_Attributes(ss, "JOB1", "we changed this value")
> > End If
> > End Sub
> >
> > Private Sub Change_Attributes(ByVal oBlk As AcadBlockReference,
ByVal
> > sTag As String, ByVal sValue As String)
> > Dim Attribs As Object
> > Dim Attrib As AcadAttributeReference
> >
> > Attribs = oBlk.GetAttributes
> >
> > For I As Integer = LBound(Attribs) To UBound(Attribs)
> > Attrib = Attribs(I)
> > If Attrib.TagString = sTag Then
> > Attrib.TextString = sValue
> > End If
> > Next I
> > End Sub
> >
> > Public Sub BuildFilter(ByVal typeArray, ByVal dataArray, ByVal
> > ParamArray gCodes())
> > Dim fType(), fData() As Object
> > Dim index As Long, i As Long
> >
> > index = LBound(gCodes) - 1
> >
> > For i = LBound(gCodes) To UBound(gCodes) Step 2
> > index = index + 1
> > ReDim Preserve fType(index)
> > ReDim Preserve fData(index)
> > fType(index) = CInt(gCodes(i))
> > fData(index) = gCodes(i + 1)
> > Next
> >
> > typeArray = fType
> > dataArray = fData
> > End Sub
> >
> >
> >
> >
> > "R. Robert Bell" wrote in message
> > news:6EB40A017DF2688E550EA2CEF382B57F@in.WebX.maYIadrTaRb...
> > > Russ,
> > >
> > > Make a procedure to get a filtered selection set of the
> BlockReference(s)
> > > you are interested in (they are called "Insert" for the filter), then
> pass
> > > the object(s) into your Change_Attributes procedure. There are plenty
of
> > > examples of filtered selection sets in this ng, or the help files, or
> even
> > > on our website.
> > >
> > > --
> > > R. Robert Bell, MCSE
> > > www.AcadX.com
> > >
> > >
> > > "Russ Green" wrote in message
> > > news:51A86D9CACBF24208E33B33EC9C6529F@in.WebX.maYIadrTaRb...
> > > | I'm just starting out on a VB.NET project to build a title block
> > > | editor/drawing manager.
> > > |
> > > | I ahve the start of some code I am playing with to try to understand
> how
> > > to
> > > | edit specific attribute values within a named block. The routine
> > > | Change_Attributes should do the trick but I'm confused about how to
> pass
> > > in
> > > | the ACAD block reference. I know the block I want to edit the
> attributes
> > > of
> > > | is.... oACAD.ActiveDocument.Blocks.Item("TITLEBLOCK_MAIN")
> > > |
> > > | Block: TITLEBLOCK_MAIN
> > > | Tag: JOB1
> > > | Value: some value
> > > |
> > > | Private Sub btnEditValue_Click(ByVal sender As System.Object,
> ByVal
> > e
> > > As
> > > | System.EventArgs) Handles btnEditValue.Click
> > > |
> > > | Change_Attributes(, "JOB1", "I changed this value")
> > > | End Sub
> > > |
> > > | Private Sub Change_Attributes(ByVal oBlk As AcadBlockReference,
> > ByVal
> > > | sTag As String, ByVal sValue As String)
> > > | Dim Attribs As Object
> > > | Dim Attrib As AcadAttributeReference
> > > |
> > > | Attribs = oBlk.GetAttributes
> > > |
> > > | For I As Integer = LBound(Attribs) To UBound(Attribs)
> > > | Attrib = Attribs(I)
> > > | If Attrib.TagString = sTag Then
> > > | Attrib.TextString = sValue
> > > | End If
> > > | Next I
> > > | End Sub
> > > |
> > > |
> > > | Can someone please help out?
> > > |
> > > | TIA
> > > | Russ
> > > |
> > > |
> > >
> > >
> >
> >
>
>