need some starts help

need some starts help

Anonymous
Not applicable
295 Views
7 Replies
Message 1 of 8

need some starts help

Anonymous
Not applicable
I need to know how to get the insert point of a block that hax already been inserted. I cant seem to figure out which to use Acadblockref or block.item? The obj browser wasn't much help.
0 Likes
296 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
You're going to use the InsertionPoint property of the AcadBlockReference object. Look up the example code for InsertionPoint -- it's for a text object but the principle is the same. To reverse it and get the insert point out, you'll have to use a Variant variable. HTH, James
0 Likes
Message 3 of 8

Anonymous
Not applicable
:-) Wow, James I see your right on top of things man. But do you mind giveing me some more help? I am a VB programer but not fimilar with this API I am having just some trouble obtaining want I want. I got the example and that helps some but instead of a text object I need a block object right? which i dont seem to be able to access. Here's what I got....... MsgBox ThisDrawing.Blocks.Count MsgBox ThisDrawing.Blocks.ObjectID MsgBox ThisDrawing.Blocks.ObjectName MsgBox ThisDrawing.Blocks.OwnerID MsgBox ThisDrawing.Blocks.Handle Dim myblock As AcadBlockReference Dim varIpoint As Variant myblock = ?????????????????? varIpoint = myblock.InsertionPoint MsgBox myblock.InsertionPoint problem is I don't know what to set myBlock to? I don't think "thisdrawing" is the right class to look under is it? PS: I like to use msgbox to test returns alot! "James Belshan" wrote in message news:40aacfea$1_2@newsprd01... > You're going to use the InsertionPoint property of the AcadBlockReference > object. Look up the example code for InsertionPoint -- it's for a text > object but the principle is the same. To reverse it and get the insert > point out, you'll have to use a Variant variable. > > > HTH, > James > >
0 Likes
Message 4 of 8

Anonymous
Not applicable
A "Block" is the definition of the object. An "Insert" or "BlockReference" is an instance of the definition in model or paperspace. Depends what block(insert) you want to examine. Is it every insert or just ones with a certain name? You might want to review the Acad object model in the help files. You can either iterate every object in model and or paper space to get the inserts Dim oBlkRef as AcadBlockReference Dim oEnt as AcadEntity For Each oEnt in oModelSpace if Type of oent is AcadBlockReference then Set oBlkRef = oEnt msgbox oBlkRef.Name whatever or you can use a filtered selection set. 'get filtered set - review help on filtering 'then once you have the selection For each oBlkRef in filteredSet1 msgbox oBlkRef.name whatever "Joshua Verdin" wrote in message news:40aad859$1_2@newsprd01... > :-) > Wow, James I see your right on top of things man. But do you mind giveing me > some more help? > > I am a VB programer but not fimilar with this API I am having just some > trouble obtaining want I want. I got the example and that helps some but > instead of a text object I need a block object right? which i dont seem to > be able to access. Here's what I got.......
0 Likes
Message 5 of 8

Anonymous
Not applicable
You can get your block variable by direct select on screen for example:
Dim BasPnt As Variant
ThisDrawing.Utility.GetEntity myblock , BasPnt, "Select a block"
Now, myblock is referencing the selected block in the drawing.
You can also obtain a reference to this block by searching it:
Set doc = ThisDrawing.Application.ActiveDocument
Set MSpace = doc.ModelSpace
Dim elem As AcadEntity
For Each elem In MSpace
With elem
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
'or .Name="Your block name..." then
Set myblock=elem
exit for
End If
End With
Next elem
MsgBox myblock.InsertionPoint is not correct because this variable is a 3D point, an array of doubles. You can also see this by adding this variable with "Add watch" command, at runtime. I always use this method to see the type of variables and what they contains.
Print your variable like this:
MsgBox "x: " & myblock.InsertionPoint(0) & " y: " & myblock.InsertionPoint(1) & " z: " & myblock.InsertionPoint(2)
Hope this help...
0 Likes
Message 6 of 8

Anonymous
Not applicable
Thanks guys this should be enough to get me started.... "Joshua Verdin" wrote in message news:40aad859$1_2@newsprd01... > :-) > Wow, James I see your right on top of things man. But do you mind giveing me > some more help? > > I am a VB programer but not fimilar with this API I am having just some > trouble obtaining want I want. I got the example and that helps some but > instead of a text object I need a block object right? which i dont seem to > be able to access. Here's what I got....... > > MsgBox ThisDrawing.Blocks.Count > MsgBox ThisDrawing.Blocks.ObjectID > MsgBox ThisDrawing.Blocks.ObjectName > MsgBox ThisDrawing.Blocks.OwnerID > MsgBox ThisDrawing.Blocks.Handle > > Dim myblock As AcadBlockReference > Dim varIpoint As Variant > myblock = ?????????????????? > > varIpoint = myblock.InsertionPoint > MsgBox myblock.InsertionPoint > > problem is I don't know what to set myBlock to? I don't think "thisdrawing" > is the right class to look under is it? > > > PS: I like to use msgbox to test returns alot! > > > > "James Belshan" wrote in message > news:40aacfea$1_2@newsprd01... > > You're going to use the InsertionPoint property of the AcadBlockReference > > object. Look up the example code for InsertionPoint -- it's for a text > > object but the principle is the same. To reverse it and get the insert > > point out, you'll have to use a Variant variable. > > > > > > HTH, > > James > > > > > >
0 Likes
Message 7 of 8

Anonymous
Not applicable
Joshua,

You write.."problem is I don't know what to set myBlock to? I don't think "thisdrawing" is the right class to look under is it?

To save you some time and let the swelling go down on your head I'd advise that you take time and review the object model for the new environment you've stepped into. If you've been doing VB a while, written your own VBA object model, or been in the Dot Net arena you know that within any new environment resides a base class structure. Take some time and envelope yourself within the AutoCAD object model and you'll save yourself weeks of unproductive effort in hours of time.

Just my .02

Regards,

Bob Coward
CADS, Inc

800-366-0946
bcoward@mindspring.com
0 Likes
Message 8 of 8

Anonymous
Not applicable
Bob, Every class structure is different, this is true. Unfortunately, I have an overwhelming amount work and school. I am sure the object model documentation is an absolutely exhilarating piece of literature, lol. Unfortunately I have not had the time or the concentration which is minimal and often over never there at all. I appreciate the suggestion and will read it ASAP. Thanks for the help.... ;-) "bcoward" wrote in message news:6919258.1084974078340.JavaMail.jive@jiveforum2.autodesk.com... > Joshua, > > You write.."problem is I don't know what to set myBlock to? I don't think "thisdrawing" is the right class to look under is it? > > To save you some time and let the swelling go down on your head I'd advise that you take time and review the object model for the new environment you've stepped into. If you've been doing VB a while, written your own VBA object model, or been in the Dot Net arena you know that within any new environment resides a base class structure. Take some time and envelope yourself within the AutoCAD object model and you'll save yourself weeks of unproductive effort in hours of time. > > Just my .02 > > Regards, > > Bob Coward > CADS, Inc > > 800-366-0946 > bcoward@mindspring.com
0 Likes