<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Some fundamental questions in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/some-fundamental-questions/m-p/2555522#M69120</link>
    <description>heres a sample i found somewhere that shows getting the modelspace &lt;BR /&gt;
blocktable record and inserting a block in it&lt;BR /&gt;
I don't think it's good code, someone said you shouldn't dispose the &lt;BR /&gt;
transaction manager but it shows at least how to get the modelspace&lt;BR /&gt;
i assume there's an object browser in dotnet like there was in vb6/vba but &lt;BR /&gt;
i'm new to this too so don't know how to tell you where to find it&lt;BR /&gt;
if you reference the acad dlls in a dotnet project i'd think you could find &lt;BR /&gt;
the object browser and point it to the autocad namespace or whatever it's &lt;BR /&gt;
called to look around&lt;BR /&gt;
good luck (this is a lot harder to find the simplest answers than i ever &lt;BR /&gt;
thought it would be)&lt;BR /&gt;
thank goodness for this group&lt;BR /&gt;
&lt;BR /&gt;
Public Shared Function InsertBlock(ByVal InsPt As Geometry.Point3d, ByVal &lt;BR /&gt;
BlockName As String, Optional ByVal XScale As Double = 1.0, Optional ByVal &lt;BR /&gt;
YScale As Double = 1.0, Optional ByVal ZScale As Double = 1.0) As &lt;BR /&gt;
DatabaseServices.ObjectId&lt;BR /&gt;
Try&lt;BR /&gt;
Dim myTransMan As DatabaseServices.TransactionManager&lt;BR /&gt;
Dim myTrans As DatabaseServices.Transaction&lt;BR /&gt;
Dim myDwg As ApplicationServices.Document&lt;BR /&gt;
Dim myBT As DatabaseServices.BlockTable&lt;BR /&gt;
Dim myBTR As DatabaseServices.BlockTableRecord&lt;BR /&gt;
Dim myAttColl As DatabaseServices.AttributeCollection&lt;BR /&gt;
Dim myEnt As DatabaseServices.Entity&lt;BR /&gt;
Dim myBTREnum As BlockTableRecordEnumerator&lt;BR /&gt;
Dim myDwgLoc As DocumentLock&lt;BR /&gt;
'Get active document and begin transaction&lt;BR /&gt;
myDwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
myDwgLoc = myDwg.LockDocument()&lt;BR /&gt;
myTransMan = myDwg.TransactionManager&lt;BR /&gt;
myTrans = myTransMan.StartTransaction&lt;BR /&gt;
'Open Block Table&lt;BR /&gt;
myBT = myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead)&lt;BR /&gt;
myBTR = &lt;BR /&gt;
myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)&lt;BR /&gt;
'Insert the Block&lt;BR /&gt;
Dim myBlockDef As BlockTableRecord = &lt;BR /&gt;
myBT(BlockName).GetObject(OpenMode.ForRead)&lt;BR /&gt;
Dim myBlockRef As New DatabaseServices.BlockReference(InsPt, &lt;BR /&gt;
myBT(BlockName))&lt;BR /&gt;
myBlockRef.ScaleFactors = New Geometry.Scale3d(XScale, YScale, ZScale)&lt;BR /&gt;
myBTR.AppendEntity(myBlockRef)&lt;BR /&gt;
myTrans.AddNewlyCreatedDBObject(myBlockRef, True)&lt;BR /&gt;
'Set Attribute values&lt;BR /&gt;
myAttColl = myBlockRef.AttributeCollection&lt;BR /&gt;
myBTREnum = myBlockDef.GetEnumerator&lt;BR /&gt;
While myBTREnum.MoveNext&lt;BR /&gt;
myEnt = myBTREnum.Current.GetObject(OpenMode.ForWrite)&lt;BR /&gt;
If TypeOf myEnt Is DatabaseServices.AttributeDefinition Then&lt;BR /&gt;
Dim myAttDef As DatabaseServices.AttributeDefinition = myEnt&lt;BR /&gt;
Dim myAttRef As New DatabaseServices.AttributeReference&lt;BR /&gt;
myAttRef.SetAttributeFromBlock(myAttDef, myBlockRef.BlockTransform)&lt;BR /&gt;
myAttColl.AppendAttribute(myAttRef)&lt;BR /&gt;
myTrans.AddNewlyCreatedDBObject(myAttRef, True)&lt;BR /&gt;
End If&lt;BR /&gt;
End While&lt;BR /&gt;
myDwgLoc.Dispose()&lt;BR /&gt;
myTrans.Commit()&lt;BR /&gt;
'Clean up&lt;BR /&gt;
myTrans.Dispose()&lt;BR /&gt;
myTransMan.Dispose()&lt;BR /&gt;
Return myBlockRef.ObjectId&lt;BR /&gt;
Catch e As Exception&lt;BR /&gt;
MsgBox(e.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen &lt;BR /&gt;
Error")&lt;BR /&gt;
End Try&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
hth&lt;BR /&gt;
mark&lt;BR /&gt;
&lt;BR /&gt;
&lt;SANGANAKSAKHA&gt; wrote in message news:6253372@discussion.autodesk.com...&lt;BR /&gt;
I'm a new convert from VBA to vb.net.&lt;BR /&gt;
&lt;BR /&gt;
Here are some fundamental questions to which I could not find unambiguous &lt;BR /&gt;
answers after searching AutoDESK, MSDN &amp;amp; Google sites:&lt;BR /&gt;
&lt;BR /&gt;
1. Is there no such thing as ModelSpace object in .Net. So, is it this &lt;BR /&gt;
because I seem to be unable to write something like this:&lt;BR /&gt;
&lt;BR /&gt;
     Dim ms1 As ModelSpce&lt;BR /&gt;
&lt;BR /&gt;
2. Is there a guide that lists all Objects and their properties and methods &lt;BR /&gt;
similar to one available fo VBA?&lt;BR /&gt;
&lt;BR /&gt;
Thanks for any help.&lt;BR /&gt;
&lt;BR /&gt;
- Sanjay Kulkarni&lt;/SANGANAKSAKHA&gt;</description>
    <pubDate>Sat, 12 Sep 2009 16:29:20 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2009-09-12T16:29:20Z</dc:date>
    <item>
      <title>Some fundamental questions</title>
      <link>https://forums.autodesk.com/t5/net-forum/some-fundamental-questions/m-p/2555520#M69118</link>
      <description>I'm a new convert from VBA to vb.net.&lt;BR /&gt;
&lt;BR /&gt;
Here are some fundamental questions to which I could not find unambiguous answers after searching AutoDESK, MSDN &amp;amp; Google sites:&lt;BR /&gt;
&lt;BR /&gt;
1. Is there no such thing as ModelSpace object in .Net. So, is it this because I seem to be unable to write something like this:&lt;BR /&gt;
&lt;BR /&gt;
     Dim ms1 As ModelSpce&lt;BR /&gt;
&lt;BR /&gt;
2. Is there a guide that lists all Objects and their properties and methods similar to one available fo VBA?&lt;BR /&gt;
&lt;BR /&gt;
Thanks for any help.&lt;BR /&gt;
&lt;BR /&gt;
- Sanjay Kulkarni</description>
      <pubDate>Sat, 12 Sep 2009 12:13:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/some-fundamental-questions/m-p/2555520#M69118</guid>
      <dc:creator>sanganaksakha</dc:creator>
      <dc:date>2009-09-12T12:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Some fundamental questions</title>
      <link>https://forums.autodesk.com/t5/net-forum/some-fundamental-questions/m-p/2555521#M69119</link>
      <description>Modelspace is a BlockTableRecord&lt;BR /&gt;
&lt;BR /&gt;
Dan</description>
      <pubDate>Sat, 12 Sep 2009 16:02:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/some-fundamental-questions/m-p/2555521#M69119</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-12T16:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: Some fundamental questions</title>
      <link>https://forums.autodesk.com/t5/net-forum/some-fundamental-questions/m-p/2555522#M69120</link>
      <description>heres a sample i found somewhere that shows getting the modelspace &lt;BR /&gt;
blocktable record and inserting a block in it&lt;BR /&gt;
I don't think it's good code, someone said you shouldn't dispose the &lt;BR /&gt;
transaction manager but it shows at least how to get the modelspace&lt;BR /&gt;
i assume there's an object browser in dotnet like there was in vb6/vba but &lt;BR /&gt;
i'm new to this too so don't know how to tell you where to find it&lt;BR /&gt;
if you reference the acad dlls in a dotnet project i'd think you could find &lt;BR /&gt;
the object browser and point it to the autocad namespace or whatever it's &lt;BR /&gt;
called to look around&lt;BR /&gt;
good luck (this is a lot harder to find the simplest answers than i ever &lt;BR /&gt;
thought it would be)&lt;BR /&gt;
thank goodness for this group&lt;BR /&gt;
&lt;BR /&gt;
Public Shared Function InsertBlock(ByVal InsPt As Geometry.Point3d, ByVal &lt;BR /&gt;
BlockName As String, Optional ByVal XScale As Double = 1.0, Optional ByVal &lt;BR /&gt;
YScale As Double = 1.0, Optional ByVal ZScale As Double = 1.0) As &lt;BR /&gt;
DatabaseServices.ObjectId&lt;BR /&gt;
Try&lt;BR /&gt;
Dim myTransMan As DatabaseServices.TransactionManager&lt;BR /&gt;
Dim myTrans As DatabaseServices.Transaction&lt;BR /&gt;
Dim myDwg As ApplicationServices.Document&lt;BR /&gt;
Dim myBT As DatabaseServices.BlockTable&lt;BR /&gt;
Dim myBTR As DatabaseServices.BlockTableRecord&lt;BR /&gt;
Dim myAttColl As DatabaseServices.AttributeCollection&lt;BR /&gt;
Dim myEnt As DatabaseServices.Entity&lt;BR /&gt;
Dim myBTREnum As BlockTableRecordEnumerator&lt;BR /&gt;
Dim myDwgLoc As DocumentLock&lt;BR /&gt;
'Get active document and begin transaction&lt;BR /&gt;
myDwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument&lt;BR /&gt;
myDwgLoc = myDwg.LockDocument()&lt;BR /&gt;
myTransMan = myDwg.TransactionManager&lt;BR /&gt;
myTrans = myTransMan.StartTransaction&lt;BR /&gt;
'Open Block Table&lt;BR /&gt;
myBT = myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead)&lt;BR /&gt;
myBTR = &lt;BR /&gt;
myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)&lt;BR /&gt;
'Insert the Block&lt;BR /&gt;
Dim myBlockDef As BlockTableRecord = &lt;BR /&gt;
myBT(BlockName).GetObject(OpenMode.ForRead)&lt;BR /&gt;
Dim myBlockRef As New DatabaseServices.BlockReference(InsPt, &lt;BR /&gt;
myBT(BlockName))&lt;BR /&gt;
myBlockRef.ScaleFactors = New Geometry.Scale3d(XScale, YScale, ZScale)&lt;BR /&gt;
myBTR.AppendEntity(myBlockRef)&lt;BR /&gt;
myTrans.AddNewlyCreatedDBObject(myBlockRef, True)&lt;BR /&gt;
'Set Attribute values&lt;BR /&gt;
myAttColl = myBlockRef.AttributeCollection&lt;BR /&gt;
myBTREnum = myBlockDef.GetEnumerator&lt;BR /&gt;
While myBTREnum.MoveNext&lt;BR /&gt;
myEnt = myBTREnum.Current.GetObject(OpenMode.ForWrite)&lt;BR /&gt;
If TypeOf myEnt Is DatabaseServices.AttributeDefinition Then&lt;BR /&gt;
Dim myAttDef As DatabaseServices.AttributeDefinition = myEnt&lt;BR /&gt;
Dim myAttRef As New DatabaseServices.AttributeReference&lt;BR /&gt;
myAttRef.SetAttributeFromBlock(myAttDef, myBlockRef.BlockTransform)&lt;BR /&gt;
myAttColl.AppendAttribute(myAttRef)&lt;BR /&gt;
myTrans.AddNewlyCreatedDBObject(myAttRef, True)&lt;BR /&gt;
End If&lt;BR /&gt;
End While&lt;BR /&gt;
myDwgLoc.Dispose()&lt;BR /&gt;
myTrans.Commit()&lt;BR /&gt;
'Clean up&lt;BR /&gt;
myTrans.Dispose()&lt;BR /&gt;
myTransMan.Dispose()&lt;BR /&gt;
Return myBlockRef.ObjectId&lt;BR /&gt;
Catch e As Exception&lt;BR /&gt;
MsgBox(e.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen &lt;BR /&gt;
Error")&lt;BR /&gt;
End Try&lt;BR /&gt;
End Function&lt;BR /&gt;
&lt;BR /&gt;
hth&lt;BR /&gt;
mark&lt;BR /&gt;
&lt;BR /&gt;
&lt;SANGANAKSAKHA&gt; wrote in message news:6253372@discussion.autodesk.com...&lt;BR /&gt;
I'm a new convert from VBA to vb.net.&lt;BR /&gt;
&lt;BR /&gt;
Here are some fundamental questions to which I could not find unambiguous &lt;BR /&gt;
answers after searching AutoDESK, MSDN &amp;amp; Google sites:&lt;BR /&gt;
&lt;BR /&gt;
1. Is there no such thing as ModelSpace object in .Net. So, is it this &lt;BR /&gt;
because I seem to be unable to write something like this:&lt;BR /&gt;
&lt;BR /&gt;
     Dim ms1 As ModelSpce&lt;BR /&gt;
&lt;BR /&gt;
2. Is there a guide that lists all Objects and their properties and methods &lt;BR /&gt;
similar to one available fo VBA?&lt;BR /&gt;
&lt;BR /&gt;
Thanks for any help.&lt;BR /&gt;
&lt;BR /&gt;
- Sanjay Kulkarni&lt;/SANGANAKSAKHA&gt;</description>
      <pubDate>Sat, 12 Sep 2009 16:29:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/some-fundamental-questions/m-p/2555522#M69120</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2009-09-12T16:29:20Z</dc:date>
    </item>
  </channel>
</rss>

