.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Some fundamental questions

2 REPLIES 2
Reply
Message 1 of 3
sanganaksakha
212 Views, 2 Replies

Some fundamental questions

I'm a new convert from VBA to vb.net.

Here are some fundamental questions to which I could not find unambiguous answers after searching AutoDESK, MSDN & Google sites:

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:

Dim ms1 As ModelSpce

2. Is there a guide that lists all Objects and their properties and methods similar to one available fo VBA?

Thanks for any help.

- Sanjay Kulkarni
2 REPLIES 2
Message 2 of 3
Danielm103
in reply to: sanganaksakha

Modelspace is a BlockTableRecord

Dan
Message 3 of 3
Anonymous
in reply to: sanganaksakha

heres a sample i found somewhere that shows getting the modelspace
blocktable record and inserting a block in it
I don't think it's good code, someone said you shouldn't dispose the
transaction manager but it shows at least how to get the modelspace
i assume there's an object browser in dotnet like there was in vb6/vba but
i'm new to this too so don't know how to tell you where to find it
if you reference the acad dlls in a dotnet project i'd think you could find
the object browser and point it to the autocad namespace or whatever it's
called to look around
good luck (this is a lot harder to find the simplest answers than i ever
thought it would be)
thank goodness for this group

Public Shared Function InsertBlock(ByVal InsPt As Geometry.Point3d, ByVal
BlockName As String, Optional ByVal XScale As Double = 1.0, Optional ByVal
YScale As Double = 1.0, Optional ByVal ZScale As Double = 1.0) As
DatabaseServices.ObjectId
Try
Dim myTransMan As DatabaseServices.TransactionManager
Dim myTrans As DatabaseServices.Transaction
Dim myDwg As ApplicationServices.Document
Dim myBT As DatabaseServices.BlockTable
Dim myBTR As DatabaseServices.BlockTableRecord
Dim myAttColl As DatabaseServices.AttributeCollection
Dim myEnt As DatabaseServices.Entity
Dim myBTREnum As BlockTableRecordEnumerator
Dim myDwgLoc As DocumentLock
'Get active document and begin transaction
myDwg = ApplicationServices.Application.DocumentManager.MdiActiveDocument
myDwgLoc = myDwg.LockDocument()
myTransMan = myDwg.TransactionManager
myTrans = myTransMan.StartTransaction
'Open Block Table
myBT = myDwg.Database.BlockTableId.GetObject(OpenMode.ForRead)
myBTR =
myBT(DatabaseServices.BlockTableRecord.ModelSpace).GetObject(OpenMode.ForWrite)
'Insert the Block
Dim myBlockDef As BlockTableRecord =
myBT(BlockName).GetObject(OpenMode.ForRead)
Dim myBlockRef As New DatabaseServices.BlockReference(InsPt,
myBT(BlockName))
myBlockRef.ScaleFactors = New Geometry.Scale3d(XScale, YScale, ZScale)
myBTR.AppendEntity(myBlockRef)
myTrans.AddNewlyCreatedDBObject(myBlockRef, True)
'Set Attribute values
myAttColl = myBlockRef.AttributeCollection
myBTREnum = myBlockDef.GetEnumerator
While myBTREnum.MoveNext
myEnt = myBTREnum.Current.GetObject(OpenMode.ForWrite)
If TypeOf myEnt Is DatabaseServices.AttributeDefinition Then
Dim myAttDef As DatabaseServices.AttributeDefinition = myEnt
Dim myAttRef As New DatabaseServices.AttributeReference
myAttRef.SetAttributeFromBlock(myAttDef, myBlockRef.BlockTransform)
myAttColl.AppendAttribute(myAttRef)
myTrans.AddNewlyCreatedDBObject(myAttRef, True)
End If
End While
myDwgLoc.Dispose()
myTrans.Commit()
'Clean up
myTrans.Dispose()
myTransMan.Dispose()
Return myBlockRef.ObjectId
Catch e As Exception
MsgBox(e.Message, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, "AutoGen
Error")
End Try
End Function

hth
mark

wrote in message news:6253372@discussion.autodesk.com...
I'm a new convert from VBA to vb.net.

Here are some fundamental questions to which I could not find unambiguous
answers after searching AutoDESK, MSDN & Google sites:

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:

Dim ms1 As ModelSpce

2. Is there a guide that lists all Objects and their properties and methods
similar to one available fo VBA?

Thanks for any help.

- Sanjay Kulkarni

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost