Tony don't know how make Commandline.vb works

Tony don't know how make Commandline.vb works

Anonymous
Not applicable
1,385 Views
7 Replies
Message 1 of 8

Tony don't know how make Commandline.vb works

Anonymous
Not applicable

Tony,

in antoher thread you helped a gentleman to work with eattedit problem. I download the code and tried to use, since I have the same situation. But I could not make it work. Could you please take a look.

the link was

http://www.caddzone.com/CommandLine.vb

can you or somebody else help me please.

 

 

 

 

Sub neweditattribute() Dim Entry As Autodesk.AutoCAD.Interop.Common.AcadEntity Do While ThisDrawing.SelectionSets.Count <> 0 ThisDrawing.SelectionSets.Item(0).Delete() Loop SelectionSet = "" sset = ThisDrawing.SelectionSets.Add("SS1") sset.SelectOnScreen() For Each Entry In sset If Entry.ObjectName = "AcDbBlockReference" Then TempT = Entry.ObjectID CommandLine.Command("_.EATTEDIT", Entry) End If Next End Sub

 

0 Likes
1,386 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable

 

Put ,"" as the third argument in the command call as in:

CommandLine.Command("_.EATTEDIT", myObjID, "")

 

 

Some improments you could make:

I: Let AutoCAD do the selection for you based on the object type, like so:
    <CommandMethod("EdAtt")> _
    Public Sub EdAtt()
        Dim dWG As Document = DocumentManager.MdiActiveDocument
        Dim selBlks As New SelectionFilter(New TypedValue() {New TypedValue(DxfCode.Start, "INSERT")})
        Dim selRes As PromptSelectionResult =dWG.Editor.GetSelection(selBlks)
        If selRes.Status = PromptStatus.OK Then
            Using tRans As Transaction = theDWG.TransactionManager.StartTransaction
                For Each insID As ObjectId In tRans.Value.GetObjectIds
                    Dim theIns As Entity = insID.GetObject(OpenMode.ForWrite)
                    CommandLine.Command("_.EATTEDIT", insID, "")
                Next
                myTRans.Commit()
            End Using
            myDWG.Editor.Regen()
        End If

    End Sub

 

II: Or use the PickFirst selection set like:

(But then you have to check for the entity type again.)

 

   <CommandMethod("EdAtt2", CommandFlags.UsePickSet)> _
    Public Sub EdAtt2()
        Dim dWG As Document = DocumentManager.MdiActiveDocument
        Dim theEd As Editor =dWG.Editor
        Dim selRes As PromptSelectionResult = theEd.SelectImplied
        If myPSR.Status = PromptStatus.OK Then

...

           'AutoCAD 2011

                   if selID.ObjectClass().DxfName="INSERT" then

                    Dim selEnt As Entity = selID.GetObject(OpenMode.ForWrite)

           'AutoCAD 2008

                    Dim selEnt As Entity = selID.GetObject(OpenMode.ForRead)
                    if selEnt.GetType().Name="INSERT" then

                      selEnt.UpgradeOpen()

...

 

0 Likes
Message 3 of 8

Anonymous
Not applicable

 

Thanks Frits for comments, and sorry for touble. I am  learning this dot net just based on try and error.

 

1-  I made changes and put it as you said like 

 

CommandLine.Command("_.EATTEDIT", myObjID, "")

Get this error :   Unsupported type in Command() methor.

 

 

 

 

2- then  I used  your suggested  improved code and as you see I don't know how to declare those types. see attached picture please. Could you please help me to declase those type variables first.

 

 

Regards,

 

 

 

0 Likes
Message 4 of 8

Anonymous
Not applicable

Of course i will help you that's our purpose on these forums

However i too have just a few days of .net experience i can't over you to much help

I would send you my project but i am at home now without the required .net source

And with a few days work out of office the earliest occasion will be Friday.

 

So these tips are suggestions without tests:

1. you probably forgot to add (all) the Autodesk import lines on top of your class

2. did you add the tony class to your project ?

3. did you wrap your EdAtt command in the main class ?

4. did you buy and read a good VB.net/AutoCAD book ? If not i can recommend you one.

 

 

 Hope this helps to solve some of your problems or else see you on Friday.

 

 

0 Likes
Message 5 of 8

Anonymous
Not applicable
Thanks frits,
It would be nice of you , if I have a real running project using that commandline feature. So I can understand what is going on. I am waitng for that.In the mean time. I would answer your questions.
1.you probably forgot to add (all) the Autodesk import lines on top of your class

This is what I import. Dont know what else should be here.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports System

2. did you add the tony class to your project ? Yes

3. did you wrap your EdAtt command in the main class ? Yes

4. did you buy and read a good VB.net/AutoCAD book ? If not i can recommend you one. Don't Have any. Would be nice of you to let me know about the name of Book

 

Regards,

 

 

0 Likes
Message 6 of 8

Anonymous
Not applicable

The book is: VB.NET for AutoCAD 2010, Jerry Winters,  ebook(Thanks Jerry great book)

 

Some more Imports:

Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Windows
Imports Autodesk.AutoCAD.LayerManager

 

There are  2  more but for now that are specials

 

 

 

 

 

0 Likes
Message 7 of 8

Anonymous
Not applicable
Thanks You for all help Frits.
The code you gave me needed some fxing,which might be usedful for others. 
Below is the working Code. Thanks again to you and Tony. 
Imports System.IO
Imports Autodesk.AutoCAD.Interop.Common
Imports System.Security
Imports System.Security.Permissions
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Windows
Imports Autodesk.AutoCAD.LayerManager
Imports Autodesk.AutoCAD.DatabaseServices





 Public Sub EdAtt()
        Dim dWG As Document = DocumentManager.MdiActiveDocument
        Dim selBlks As New SelectionFilter(New TypedValue() {New TypedValue(DxfCode.Start, "INSERT")})
        Dim selRes As PromptSelectionResult = dWG.Editor.GetSelection(selBlks)
        If selRes.Status = PromptStatus.OK Then
            Using tRans As Transaction = dWG.TransactionManager.StartTransaction
                For Each insID As ObjectId In selRes.Value.GetObjectIds
                    Dim theIns As Entity = insID.GetObject(OpenMode.ForWrite)
                    CommandLine.Command("_.EATTEDIT", insID, "")
                Next
                tRans.Commit()
            End Using

            dWG.Editor.Regen()
        End If
    End Sub

 

0 Likes
Message 8 of 8

Anonymous
Not applicable

Youre welcome

0 Likes