crwncad702 Posted August 21, 2009 Posted August 21, 2009 Evening everyone - I was curious if anyone knew a good way that I can get the objectid of a block when a block name is known and in the dwg. I have been having a hard time getting it to work right... I am still trying to learn vbnet. Secondly once I obtain that objectid i am trying to set Dimblk to that id. However if the id is not present I will need to import it. Sorry if this has been asked, but I haven't found very many solutions that make much sense for what i am trying to do or they are coded in such a way that I am unsure how to apply it to my code. Here is the code i have thus far: Private Function crwn_initdim(ByVal dimname As String, ByVal dimscale As Double, ByVal dimangdec As Integer, ByVal dimaltunits As Integer, ByVal dimaltdec As Integer, _ ByVal dimaltf As Integer, ByVal dimaltround As Integer, ByVal dimaltdec1 As Integer, ByVal dimaltzsup As Integer, ByVal dimaltunits1 As Integer, _ ByVal dimaltsup As Integer, ByVal dimapost As String, ByVal dimarcsymbol As Integer, ByVal dimarrowsize As Integer, ByVal dimatfit As Integer, _ ByVal dimaunit As Integer, ByVal dimazin As Integer, ByVal dimblock As String) Dim crwn_dimid As ObjectId = Nothing 'dimid Dim crwn_doclock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument() Dim crwn_database As Database = Application.DocumentManager.MdiActiveDocument.Database Dim crwn_transaction As Transaction = crwn_database.TransactionManager.StartTransaction() Dim crwn_dimstyle As DimStyleTableRecord Try Dim crwn_dimblktbl As BlockTable = crwn_transaction.GetObject(crwn_database.BlockTableId, OpenMode.ForNotify, False) Dim crwn_dimtable As DimStyleTable = crwn_transaction.GetObject(crwn_database.DimStyleTableId, OpenMode.ForRead, False) If crwn_dimblktbl.Has(dimblock) = False Then MsgBox("Warning") Else 'ObjectId End If If crwn_dimtable.Has(dimname) = False Then crwn_dimstyle = New DimStyleTableRecord crwn_dimstyle.Name = dimname crwn_dimstyle.Dimscale = dimscale crwn_dimstyle.Dimadec = dimangdec crwn_dimstyle.Dimalt = dimaltunits crwn_dimstyle.Dimaltd = dimaltdec crwn_dimstyle.Dimaltf = dimaltf crwn_dimstyle.Dimaltrnd = dimaltround crwn_dimstyle.Dimalttd = dimaltdec1 crwn_dimstyle.Dimalttz = dimaltzsup crwn_dimstyle.Dimaltu = dimaltunits1 crwn_dimstyle.Dimaltz = dimaltsup crwn_dimstyle.Dimapost = dimapost crwn_dimstyle.Dimarcsym = dimarcsymbol crwn_dimstyle.Dimasz = dimarrowsize crwn_dimstyle.Dimatfit = dimatfit crwn_dimstyle.Dimaunit = dimaunit crwn_dimstyle.Dimazin = dimazin crwn_dimstyle.Dimblk = dimblock crwn_dimtable.UpgradeOpen() crwn_dimtable.Add(crwn_dimstyle) crwn_transaction.AddNewlyCreatedDBObject(crwn_dimstyle, True) crwn_dimtable.DowngradeOpen() End If crwn_dimid = crwn_dimtable.Item(dimname) crwn_transaction.Commit() Catch ex As Exception crwn_transaction.Abort() Finally crwn_transaction.Dispose() crwn_doclock.Dispose() End Try Return crwn_dimid End Function Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.