Message 1 of 7
AutoCAD.Net Problem Arraying Dynamic Blocks
Not applicable
06-01-2010
03:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I hope someone can help with this one as i have searched the forums and the Autodesk API documentation and have come up empty.
I has some code in VB.NET using the Autodesk managed API to insert blocks (static and dynamic) from a repository, as it inserts the blocks it sets attributes and dynamic property values. (This part works fine)
The function I am having issues with arrays an already inserted blocks (again static and dynamic, this is working perfectly for the static blocks)
My comments in brackets are describing the issue however in summary when i attempt to create a new blockreference to one of the dynamic blocks and add it to the database it forgets (not the best word i know) that it is a dynamic block and becomes static.
Here is the section of code in question:
Dim currentblocktable As BlockTable = currentTransaction.GetObject(currentDatabase.BlockTableId, OpenMode.ForRead)
Dim currentBlockTableRecord As BlockTableRecord = currentTransaction.GetObject( _
currentblocktable(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim columns As Integer = 1
Dim rows As Integer = 1
While columns < numberOfColumns
(At this point the _blockReference object has been retrieved from its ObjectID which is passed into the arraying function)
Dim newBlockRef As BlockReference = _blockReference.Clone()
(If at this point i retrieve the DynamicBlockTableRecord of the cloned object it returns the correct entry)
Dim newPoint As Point2d = PolarPoints(arrayBasePoint, 0, arrayProperties.HorizontalSpacing * columns + 1)
Dim vec2d As Vector2d = arrayBasePoint.GetVectorTo(newPoint)
Dim vec3d As Vector3d = New Vector3d(vec2d.X, vec2d.Y, 0)
newBlockRef.TransformBy(Matrix3d.Displacement(vec3d))
(If at this point i retrieve the DynamicBlockTableRecord of the cloned object it returns the correct entry)
currentBlockTableRecord.AppendEntity(newBlockRef)
(From this point on the BlockReference which the object newBlockReference refers to is no longer dynamic and if i return the
BlockTableRecord or the DynamicBlockTableRecord for this it refers to a block called *Uxxx where
xxx is a numeric value, I understand that this blockRecord is part of the make up of the Dynamic block but why is it losing the
reference to the correct DynamicBlockTableRecord when it is appended to modelspace?)
currentTransaction.AddNewlyCreatedDBObject(newBlockRef, True)
columns += 1
End While
Finally is there a good place to go for an explanation of what the clone function actually does? As i have googled the life out of it and cant find any explanation of what this function actually does so am calling it blindly and examining the results. Which i dont like doing!
Any Help appreciated thanks. Edited by: PSharpe on Jun 1, 2010 10:03 AM
I hope someone can help with this one as i have searched the forums and the Autodesk API documentation and have come up empty.
I has some code in VB.NET using the Autodesk managed API to insert blocks (static and dynamic) from a repository, as it inserts the blocks it sets attributes and dynamic property values. (This part works fine)
The function I am having issues with arrays an already inserted blocks (again static and dynamic, this is working perfectly for the static blocks)
My comments in brackets are describing the issue however in summary when i attempt to create a new blockreference to one of the dynamic blocks and add it to the database it forgets (not the best word i know) that it is a dynamic block and becomes static.
Here is the section of code in question:
Dim currentblocktable As BlockTable = currentTransaction.GetObject(currentDatabase.BlockTableId, OpenMode.ForRead)
Dim currentBlockTableRecord As BlockTableRecord = currentTransaction.GetObject( _
currentblocktable(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
Dim columns As Integer = 1
Dim rows As Integer = 1
While columns < numberOfColumns
(At this point the _blockReference object has been retrieved from its ObjectID which is passed into the arraying function)
Dim newBlockRef As BlockReference = _blockReference.Clone()
(If at this point i retrieve the DynamicBlockTableRecord of the cloned object it returns the correct entry)
Dim newPoint As Point2d = PolarPoints(arrayBasePoint, 0, arrayProperties.HorizontalSpacing * columns + 1)
Dim vec2d As Vector2d = arrayBasePoint.GetVectorTo(newPoint)
Dim vec3d As Vector3d = New Vector3d(vec2d.X, vec2d.Y, 0)
newBlockRef.TransformBy(Matrix3d.Displacement(vec3d))
(If at this point i retrieve the DynamicBlockTableRecord of the cloned object it returns the correct entry)
currentBlockTableRecord.AppendEntity(newBlockRef)
(From this point on the BlockReference which the object newBlockReference refers to is no longer dynamic and if i return the
BlockTableRecord or the DynamicBlockTableRecord for this it refers to a block called *Uxxx where
xxx is a numeric value, I understand that this blockRecord is part of the make up of the Dynamic block but why is it losing the
reference to the correct DynamicBlockTableRecord when it is appended to modelspace?)
currentTransaction.AddNewlyCreatedDBObject(newBlockRef, True)
columns += 1
End While
Finally is there a good place to go for an explanation of what the clone function actually does? As i have googled the life out of it and cant find any explanation of what this function actually does so am calling it blindly and examining the results. Which i dont like doing!
Any Help appreciated thanks. Edited by: PSharpe on Jun 1, 2010 10:03 AM