Change color of last inserted block
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Change color of last inserted block

 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA
Author Message
TomV
Guest





Posted: Fri Mar 18, 2005 2:09 am    Post subject: Change color of last inserted block Reply with quote

I've successfully inserted a block into my drawing. Now I want to change the color of the last inserted block (color is set to ByBlock). How do I accomplish this?

I believe I want to use a selection set "Select" method and mode "acSelectionSetLast":

objSS.Select acSelectionSetLast

But then what do I do next?

Getting my head wrapped around these VB classes and collections of collections of collections gets very confusing.

Help!!! lol.

Back to top
Jeff Mishler
Guest





Posted: Fri Mar 18, 2005 2:13 am    Post subject: Re: Change color of last inserted block Reply with quote

How are you inserting the block? What are you using to trigger the color
change?

--
Jeff
check out www.cadvault.com
"TomV" <nospam@address.withheld> wrote in message
news:3631484.1111093798932.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
I've successfully inserted a block into my drawing. Now I want to change
the color of the last inserted block (color is set to ByBlock). How do I
accomplish this?

I believe I want to use a selection set "Select" method and mode
"acSelectionSetLast":

objSS.Select acSelectionSetLast

But then what do I do next?

Getting my head wrapped around these VB classes and collections of
collections of collections gets very confusing.

Help!!! lol.
Back to top
Tom Roberts
Guest





Posted: Fri Mar 18, 2005 6:11 am    Post subject: Re: Change color of last inserted block Reply with quote

If you have used the InsertBlock method you will have a reference to the new
BlockReference and you can change its Color property

Sub InsertBlk()

Dim BlkRef As AcadBlockReference
Dim InstPnt As Variant

InstPnt = ThisDrawing.Utility.GetPoint(, "Pick insertion point")
Set BlkRef = ThisDrawing.ModelSpace.InsertBlock(InstPnt, "Your_Blk", 1#,
1#, 1#, 0#)
BlkRef.Color = acGreen

End Sub

--
Regards
Tom Roberts
__________________________
MechWest Design & Drafting
Perth, Western Australia


"TomV" <nospam@address.withheld> wrote in message
news:3631484.1111093798932.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
I've successfully inserted a block into my drawing. Now I want to change
the color of the last inserted block (color is set to ByBlock). How do I
accomplish this?

I believe I want to use a selection set "Select" method and mode
"acSelectionSetLast":

objSS.Select acSelectionSetLast

But then what do I do next?

Getting my head wrapped around these VB classes and collections of
collections of collections gets very confusing.

Help!!! lol.


Back to top
TomV
Guest





Posted: Fri Mar 18, 2005 7:06 pm    Post subject: Re: Change color of last inserted block Reply with quote

Tom - thanks for the help, that worked!

Ok, that was too dang easy. But, I am confused about something. I use the Intellisense to show me the members as I type. Why doesn't the "color" property show in the list when I type "objBlockRef."? I went ahead and put the ".color" as Tom stated and it does work - even though it didn't show up using Intellisense.

My code is shown below:

Private Sub cmdInsertBlock_Click()
Dim objBlockRef As AcadBlockReference
Dim varInsertionPoint As Variant
Dim strFileName As String

strFileName = "c:\acadwork\other\bubble2.dwg"

Me.Hide
With ThisDrawing.Utility
.InitializeUserInput 1
varInsertionPoint = .GetPoint(, vbCr & "Pick the insert point: ")
End With
On Error Resume Next
Set objBlockRef = ThisDrawing.ModelSpace.InsertBlock(varInsertionPoint, _
strFileName, 1, 1, 1, 0)
If Err Then
MsgBox "Unable to insert this block"
Exit Sub
End If
objBlockRef.color = acGreen
objBlockRef.Update

Me.Show
End Sub
Back to top
Alfred NESWADBA
Guest





Posted: Fri Mar 18, 2005 10:23 pm    Post subject: Re: Change color of last inserted block Reply with quote

i guess that you are working with acad2005, the color property in 2005 is supported, but as the
help says, maybe not supported in future releases.

- alfred -


In article <26185163.1111154837079.JavaMail.jive@jiveforum1.autodesk.com>, nospam@address.withheld says...
Quote:
Tom - thanks for the help, that worked!

Ok, that was too dang easy. But, I am confused about something. I use the Intellisense to show me the members as I type. Why doesn't the "color" property show in the list when I type "objBlockRef."? I went ahead and put the ".color" as Tom stated and it does work - even though it didn't show up using Intellisense.

My code is shown below:

Private Sub cmdInsertBlock_Click()
Dim objBlockRef As AcadBlockReference
Dim varInsertionPoint As Variant
Dim strFileName As String

strFileName = "c:\acadwork\other\bubble2.dwg"

Me.Hide
With ThisDrawing.Utility
.InitializeUserInput 1
varInsertionPoint = .GetPoint(, vbCr & "Pick the insert point: ")
End With
On Error Resume Next
Set objBlockRef = ThisDrawing.ModelSpace.InsertBlock(varInsertionPoint, _
strFileName, 1, 1, 1, 0)
If Err Then
MsgBox "Unable to insert this block"
Exit Sub
End If
objBlockRef.color = acGreen
objBlockRef.Update

Me.Show
End Sub
Back to top
TomV
Guest





Posted: Sat Mar 19, 2005 7:53 pm    Post subject: Re: Change color of last inserted block Reply with quote

Thanks Alfred, I now see that the color property is obsolete. Should I be using TrueColor instead? I'd like to go ahead and program it to work with future versions.

Thanks!
Back to top
Alfred NESWADBA
Guest





Posted: Sun Mar 20, 2005 12:00 am    Post subject: Re: Change color of last inserted block Reply with quote

it is supported in acad2006 and i would therefore make a sub/function to set
the color-property using now ".color" (because it's quicker) and when
autodesk decides to cancel the color-property you would have to change
only one sub within all your app's.

- alfred -

In article <4752002.1111244043156.JavaMail.jive@jiveforum2.autodesk.com>, nospam@address.withheld says...
Quote:
Thanks Alfred, I now see that the color property is obsolete. Should I be using TrueColor instead? I'd like to go ahead and program it to work with future versions.

Thanks!
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> VBA All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB