Alternative Attribute command
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I want write a command for attribute editing. The command check if the block name is equal to a string and if yes make some operation, if no continue with DDEDIT standard command.
The program work well if the block name is not the some of the string. When the name is the some the program make the correct operation but then run also the ddedit command.
there is a way for break the command?
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Colors
Imports System
Imports System.Windows.Forms
Imports System.Math
'Imports System.Web.Mail
Imports Microsoft.Office.Core
Imports Microsoft.Office.Interop
'Imports Microsoft.Office.Interop.Outlook
Imports System.Runtime.InteropServices
Imports Autodesk.AutoCAD.Interop
Public ClassreactorDim bEditCommand AsBooleanDim bDoRepositioning AsBoolean
<CommandMethod("AddEvents")> _
PublicSubplantDbEvents()
Dim doc AsDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db AsDatabase = HostApplicationServices.WorkingDatabase()
'AddHandler db.ObjectOpenedForModify, New ObjectEventHandler(AddressOf objOpenedForMod)AddHandler doc.CommandWillStart, NewCommandEventHandler(AddressOfcmdWillStart)
'AddHandler doc.CommandEnded, New CommandEventHandler(AddressOf cmdEnded)
bEditCommand =
False
bDoRepositioning =
FalseEndSubPublicSub cmdWillStart(ByVal o AsObject, ByVal e AsCommandEventArgs)
Dim ed AsEditor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
TryIf e.GlobalCommandName = "DDEDIT"Or e.GlobalCommandName = "EATTEDIT"Then
Dim fr2 AsNewFerriDim strNomeBlocco AsStringDim myDwg AsDocument'Dim myBT As BlockTable'Dim myBTR As BlockTableRecordDim myDB As DatabaseServices.DatabaseDim myTransMan As DatabaseServices.TransactionManagerDim myTrans As DatabaseServices.TransactionDim myEd As EditorInput.EditorDim myPSR As EditorInput.PromptSelectionResult
Dim TargetBlockRef As DatabaseServices.BlockReference
myDB = ApplicationServices.
Application.DocumentManager.MdiActiveDocument.Database
myDwg = Autodesk.AutoCAD.ApplicationServices.
Application.DocumentManager.MdiActiveDocument
strNomeBlocco =
"FERRI-P"
myTransMan = myDB.TransactionManager
myTrans = myTransMan.StartTransaction
myEd = myDwg.Editor
a2: myPSR = myEd.SelectImplied
SelectCasemyPSR.Status
Case EditorInput.PromptStatus.OK
SelectCasemyPSR.Value.Count
Case1
Dim mySelobj As EditorInput.SelectedObjectDim myAcadEnt As DatabaseServices.Entity
For I = 1 TomyPSR.Value.Count
mySelobj = myPSR.Value.Item(I - 1)
myAcadEnt = mySelobj.ObjectId.GetObject(DatabaseServices.
OpenMode.ForRead)
TargetBlockRef = myAcadEnt
If Microsoft.VisualBasic.Left$(UCase(TargetBlockRef.Name), 5) = "FERRI"Then
fr2.Show()
GoToA15
EndIf
NextI
CaseIs> 1
MsgBox(
"Seleziona un solo blocco delle Posizioni")
myPSR =
NothingGoToa2
Case ElseEndSelectCase EditorInput.PromptStatus.Error
' GoTo a3
' Case EditorInput.PromptStatus.Cancel
EndSelectEndIfCatch ex As System.Exception
ed.WriteMessage(
"Error in cmdWillStart: "+ ex.Message)
EndTry
A15:
EndSub
End
Class