
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I am trying to put something together that will allow a user to select objects in AutoCAD and then place a block at all the selected points.
Below I have pasted the code that I have so far, but have not been able to test this to see what happens because the Dim ofd part is giving me an error that I have not been able to figure out. I am only a beginner at this so my code may be wrong and/or ugly.
The error that I am getting says that :
Argument not specified for parameter "flags" of "Public Sub New(title As String, defaultName As String, extension As String, dialogName As String, flags As Autodesk.AutoCAD.Windows.OpenFileDialog.OpenFileDialogFlags)
Code:
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Windows
PublicClass Class1
<CommandMethod("pntblk")> _
PublicSub PntBlk()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim blktbl As BlockTable
blktbl = trans.GetObject(db.BlockTableId, _
OpenMode.ForRead)
Dim ofd AsNew OpenFileDialog(dialogName:="Block Selection")
Dim ppo As PromptPointOptions = New PromptPointOptions(SelectionMethod.Crossing)
Dim ppr As PromptPointResult = ed.GetPoint(ppo)
Dim ndb As Database = New Database(False, True)
ndb.ReadDwgFile(ofd.Filename, FileOpenMode.OpenForReadAndReadShare,True, Nothing)
Dim name AsString = SymbolUtilityServices.GetBlockNameFromInsertPathName(ofd.Filename)
Dim id As ObjectId = db.Insert(name, ndb, True)
Dim btr As BlockTableRecord = CType(trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite), BlockTableRecord)
Dim inst As BlockReference = New BlockReference(ppr.Value, id)
btr.AppendEntity(inst)
inst.SetDatabaseDefaults()
trans.AddNewlyCreatedDBObject(inst,True)
trans.Commit()
EndUsing
End Sub
End Class
Any Assistance will be appreciated.
Solved! Go to Solution.