inneedofmajorhelp Posted December 9, 2011 Posted December 9, 2011 (edited) i am creating an app that opens a drawing that automatically assiagns a tag to the title block. every thing is fine till it starts looking through the objects. i get 'failed to get document object' i am also using common and interop imports. this is where the problem occurs. it gets to the search for the objects then it fails. i am also wondering if there is a way to limit the search since i am only caring about blocks. For Each MyObj In MyDwgDoc.ModelSpace booMfgTag = False '** Find all Titleblocks If MyObj.ObjectName = "AcDbBlockReference" Then If MyObj.Name = "MSP-B-BORDER" Then XOffset = (12 + 47 / 64) - 1.875 DScale = 1.0# booMfgTag = True ElseIf MyObj.Name = "MSP-D-BORDER" Then XOffset = (24 + 29 / 32) - 3.75 DScale = 2.0# booMfgTag = True ElseIf MyObj.Name = "B-BORDER" Then XOffset = (12 + 47 / 64) - 1.875 DScale = 1.0# booMfgTag = True ElseIf MyObj.Name = "D-BORDER" Then XOffset = (24 + 29 / 32) - 3.75 DScale = 2.0# booMfgTag = True ElseIf MyObj.Name = "BLOCK1" Then XOffset = (24 + 29 / 32) - 3.75 DScale = 2.0# booMfgTag = True End If If booMfgTag Then TBInsrtPt = MyObj.InsertionPoint '** Set-up and insert MfgTag InsertPnt(0) = TBInsrtPt(0) + XOffset * MyObj.XScaleFactor InsertPnt(1) = TBInsrtPt(1) InsertPnt(2) = TBInsrtPt(2) MTObj = MyDwgDoc.ModelSpace.InsertBlock(InsertPnt, strBlock, _ MyObj.XScaleFactor * DScale, MyObj.YScaleFactor * DScale, MyObj.ZScaleFactor * DScale, 0.0#) '** Change the attributes of the new block RetVal = MTObj.GetAttributes If IsDBNull(DataGridView3.Rows(ridx).Cells(4).Value) Then DataGridView3.Rows(ridx).Cells(4).Value = " " End If If IsDBNull(DataGridView3.Rows(ridx).Cells(5).Value) Then DataGridView3.Rows(ridx).Cells(5).Value = " " End If If IsDBNull(DataGridView3.Rows(ridx).Cells(6).Value) Then DataGridView3.Rows(ridx).Cells(6).Value = " " End If If IsDBNull(DataGridView3.Rows(ridx).Cells(7).Value) Then DataGridView3.Rows(ridx).Cells(7).Value = " " End If For intI = LBound(RetVal) To UBound(RetVal) If RetVal(intI).TagString = "CSJOB" Then RetVal(intI).TextString = DataGridView3.Rows(ridx).Cells(3).Value If RetVal(intI).TagString = "LOCATION" Then RetVal(intI).TextString = DataGridView3.Rows(ridx).Cells(4).Value If RetVal(intI).TagString = "DESCRIPTION" Then RetVal(intI).TextString = DataGridView3.Rows(ridx).Cells(5).Value If RetVal(intI).TagString = "RESPONSIBLE1" Then RetVal(intI).TextString = DataGridView3.Rows(ridx).Cells(6).Value If RetVal(intI).TagString = "RESPONSIBLE2" Then RetVal(intI).TextString = DataGridView3.Rows(ridx).Cells(7).Value If RetVal(intI).TagString = "QTY" Then RetVal(intI).TextString = DataGridView3.Rows(ridx).Cells(1).Value Next intI booChange = True End If End If Next Edited December 12, 2011 by inneedofmajorhelp Quote
inneedofmajorhelp Posted December 9, 2011 Author Posted December 9, 2011 i am creating an application in VB.NET express 2010 using .NET FRAMEWORK 4.0. i have been programming for years but this is my first stab at autocad developer. i am trying to dynamically open a drawing and search through all block objects then attach a tag to the title block. right now it opens CAD and opens the drawing.. then i get 'Failed to get document object' and it throws the error infinitely. i am using AutoCAD 2012 as well. so i need help on the proper method to locate and edit the blocks and then exit the subroutine. here is the relevant code for where the headache occurs. OHHH.. is there an import i am missing as well. i just have the interop and common imports. Quote
tzframpton Posted December 9, 2011 Posted December 9, 2011 Just to throw it out there, try the forum over at http://www.theswamp.org - they are heavy into programming over there, a lot of .NET guru's and what not. Just spreading the word is all. Quote
SLW210 Posted December 12, 2011 Posted December 12, 2011 Please read CODE POSTING GUIDELINES and edit your post. Quote
SLW210 Posted December 12, 2011 Posted December 12, 2011 Please make only one post for the same question. I combined threads. Quote
inneedofmajorhelp Posted December 12, 2011 Author Posted December 12, 2011 ok i have reposted using the code guidlines.. i was wondering where that was .. so everything should be in order for the post.. now i hope it is displayed in such a way that i will get some good tips Quote
tzframpton Posted December 12, 2011 Posted December 12, 2011 ok i have reposted using the code guidlines.. i was wondering where that was .. so everything should be in order for the post.. now i hope it is displayed in such a way that i will get some good tips Don't forget my post above. You would get better and faster help over there. 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.