TheSwamp
Code Red => VB(A) => Topic started by: rainier on October 04, 2007, 09:41:36 PM
-
how to get all data in a block without exploding a block..? in VBA? :-(
especially attributes... please help me..thanks!! :angel:
-
is there anyone can help me in getting the data...?? hope some can help me..thanks.. :-(
-
Look at the GetAttributes method of the BlockRef object. As for the rest of the data, you have to go back to the block definition and then apply whatever transformations have been done to the individual blockref you are looking at.
-
how about the entities inside the block... how can i get the data...?? if i have circles or rectangles..etc. inside a block..
-
If I say iterate the Block Items, will that help ?
A Block is simply a collection of Objects
-
A better description of what you want to do with the info would help.
Many learners take a while to see the differenece between a block and a blockattribute.
It's a very simple matter to extract info on the entities within a block but quite complicated to mess with the transformations that Chuck mentioned.
-
in attributes i have no problem on it but in the objects inside a block... i cant get the information what i want.. indeed its a mess..but any other ways in getting it..in a nice way :-)
i just need the object inside a block... :-(
-
kerry,
how to get all of it..if its block reference... there is no item found but in acadblock it have an items... :-(
If I say iterate the Block Items, will that help ?
A Block is simply a collection of Objects
-
I don't do VBA, but have you tried something like ..
Dim theBlock As AcadBlock
Set theBlock = ThisDrawing.Blocks.Item("WhateverBlock")
Dim aEntity As AcadEntity
For Each aEntity In theBlock
' do stuff here
Next aEntity
Try that and step through the code with the Locals window open .. watch the aEntity variable properties
-
kerry,
if i have multiple blocks in my drawings how can i get a specific block that i want???
sample block "DETAILS" <-- i have 100 items in my drawings...
the main reason why i need the information inside a block because i need to know inside a block, circle or rectangle location in a block not the bounding box of the block..its confusing... :|
Or how do i know if the block intersect in a line or polyline in my drawings....
I don't do VBA, but have you tried something like ..
Dim theBlock As AcadBlock
Set theBlock = ThisDrawing.Blocks.Item("WhateverBlock")
Dim aEntity As AcadEntity
For Each aEntity In theBlock
' do stuff here
Next aEntity
Try that and step through the code with the Locals window open .. watch the aEntity variable properties
-
rainier
I'll leave you in the good hands of the VB'ers amongst us ...
but it may be helpfull if you post the block you've using
and post some of the code you've tried so far.
Are you trying for a fully programmatic solution ?
What are the rules for each block ?
Do you know how to select a block insertion in VBA ?
Do you know how to retrieve a block definition from the Blocks Table/Collection ?
Do you know how to iterate through a collection ?
Do you know how to retrieve the X,X,Z scale from a block ?
Do you know how to do matrix translations ?
Do you know how to do vector multiplication and addition ?
-
kerry,
thanks for the questions and responses that u gave to me... it helps me to get some idea to our questions..
and lastly on the second question that u give to me like,
"Do you know how to retrieve a block definition from the Blocks Table/Collection ?"
how to retrieve a block definition from the Blocks Table/Collection?? any idea??
thanks again.. :-)
-
............
and lastly on the second question that u give to me like,
"Do you know how to retrieve a block definition from the Blocks Table/Collection ?"
how to retrieve a block definition from the Blocks Table/Collection?? any idea??
How about something similar to ;
Dim theBlock As AcadBlock
Set theBlock = ThisDrawing.Blocks.Item("WhateverBlockNameYouWant")
-
To add a little.
Private Sub FindTheBlock()
Dim oBref As AcadBlockReference
Dim B As AcadBlock
Dim Pt As Variant
Dim C As AcadCircle
Dim X As Double
Dim Ent As AcadEntity
'get the BlockReference
ThisDrawing.Utility.GetEntity oBref, Pt, "Pick a block reference:"
'Use the BlockReference's name to find the block definition
Set B = ThisDrawing.Blocks(oBref.Name)
'Cycle through the entities in the block
For Each Ent In B
If TypeOf Ent Is AcadCircle Then
'Store the circle in an object variable
Set C = Ent
Exit For
End If
Next Ent
Dim L As AcadLine
ThisDrawing.Utility.GetEntity L, Pt, "Pick a line:"
L.Move oBref.InsertionPoint, B.Origin
Pt = L.EndPoint
'circle formula x^2+y^2=radius^2
X = Sqr(C.radius ^ 2 - Pt(1) ^ 2)
If Pt(0) < 0 Then X = -X
Debug.Print Pt(0), X
If Abs(Pt(0) - X) < 0.00000001 Then
MsgBox "The line ends on the circle."
End If
L.Move B.Origin, oBref.InsertionPoint
End Sub
Now if the BlockReference you pick has a rotation of zero and a normal value of (0,0,1)
then the circle's center in the BlockReference will be the same distance and direction from BlockReference InsertionPoint as the blocks circles center is from the block's origin.
-
thanks Bryco and Kerry... :angel:
it helps alot..