Jump to content

need help with developer 2012 with vb.net 2010


Recommended Posts

Posted (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 by inneedofmajorhelp
Posted

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.

Posted

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.

 

:)

Posted

Please make only one post for the same question. I combined threads.

Posted

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 :P

Posted
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 :P

Don't forget my post above. You would get better and faster help over there. :)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...