- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to insert a block (using .Net) that does not already exist on the drawing. It is on a network share, which is in the search path. If I, from the command line insert the block, it finds it ok and inserts it. But when I do this from .Net code it does not search for the block. So how do you get it to search for the block and insert it?
Here is a code snippet I'm using to insert the block:
Dim myDwg AsDocument = Application.DocumentManager.MdiActiveDocument
Using myDocLock AsDocumentLock= myDwg.LockDocument()
Using myTrans AsTransaction= myDwg.TransactionManager.StartTransaction
'Open the database for WriteDim myBT AsBlockTable = CType(myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead), BlockTable)
Dim myModelSpace AsBlockTableRecord = CType(myBT(BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite), BlockTableRecord)
'Insert the BlockDim myBlockDef AsBlockTableRecord = CType(myBT(BlockName).GetObject(OpenMode.ForRead), BlockTableRecord)
Dim myBlockRef AsNew DatabaseServices.BlockReference(InsertPoint, myBT(BlockName))
myBlockRef.ScaleFactors =
New Geometry.Scale3d(XScale, YScale, ZScale)
myModelSpace.AppendEntity(myBlockRef)
myTrans.AddNewlyCreatedDBObject(myBlockRef,
True)
myBlkID = myBlockRef.ObjectId
Thanks in advance,
Jim
Solved! Go to Solution.