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

How to EATTEDIT block inserted programmatically

9 REPLIES 9
Reply
Message 1 of 10
Anonymous
1518 Views, 9 Replies

How to EATTEDIT block inserted programmatically

I am converting a VBA application into C# that inserts a block reference into paperspace.
I can get the block inserted and the attributes attached to it.
How do I get the EATTEDIT function or a similar attribute editor to launch so that the user can fill in the attribute values?

In VBA I used SendCommand to launch the INSERT command and the attribute editor was launched as part of that function.

ThisDrawing.SendCommand "(command " & Chr(34) & "-insert" & Chr(34) & " " & Chr(34) & insertBlk & Chr(34) & " PAUSE " _
& hScale & " " & vScale & " " & " PAUSE " & ")" & vbCr

In C# I am getting the ObjectId of the BlockDefinition, then creating a BlockReference with it:

//Get the ObjectId of the block definition
ObjectId bdId = bt[selectedBlock];

//Set a default insertion point for the block reference
Point3d startPt = new Point3d(0, 0, 0);

//Instantiate a block reference using the point and the table definition
BlockReference br = new BlockReference(startPt, bdId);

Then I use two JIGs to get the block insertion point and get the rotation.

I then commit all this to the database within the transaction:

//Use the transaction to commit the changes
tr.AddNewlyCreatedDBObject(ar, true);

How do I get the attribute editor interface to come up???

I tried SendStringToExecute, but cannot figure out how to send the ObjectId of the BlockReference through:

doc.SendStringToExecute("_eattedit ",false,false,true);
9 REPLIES 9
Message 2 of 10
chiefbraincloud
in reply to: Anonymous

I have looked, and I do not see a way in the Managed API to invoke the Attribute Editor, so, If this is a one-at-a-time operation, you could use SendStringToExecute and just pass "L" along with the command to use the "Last" selection set.
doc.SendStringToExecute("_eattedit L ",false,false,true);

Keep in mind that unlike the VBA SendCommand, the .NET SendStringToExecute is Asynchronous and your .NET code will complete and return control to AutoCAD before the SendString actually Executes, so this option will only work if you don't have code after the SendString that needs the SendString to be done. For Instance, if you wanted to read out the value of one or more attributes that the user might change.

If, for some reason, that won't work for your plan, then about the only thing I could suggest is to create your own form which resembles the Attribute Editor dialog, use it to get values from the user, and populate the attributes with your own code, all of which would happen synchronously.
Dave O.                                                                  Sig-Logos32.png
Message 3 of 10
Anonymous
in reply to: Anonymous

Is your code running from a registered command,
or a modeless dialog or palette?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message
news:6346585@discussion.autodesk.com...
I am converting a VBA application into C# that inserts a block reference into
paperspace.
I can get the block inserted and the attributes attached to it.
How do I get the EATTEDIT function or a similar attribute editor to launch so
that the user can fill in the attribute values?

In VBA I used SendCommand to launch the INSERT command and the attribute editor
was launched as part of that function.

ThisDrawing.SendCommand "(command " & Chr(34) & "-insert" & Chr(34) & " " &
Chr(34) & insertBlk & Chr(34) & " PAUSE " _
& hScale & " " & vScale & " " & " PAUSE " & ")" & vbCr

In C# I am getting the ObjectId of the BlockDefinition, then creating a
BlockReference with it:

//Get the ObjectId of the block definition
ObjectId bdId = bt[selectedBlock];

//Set a default insertion point for the block reference
Point3d startPt = new Point3d(0, 0, 0);

//Instantiate a block reference using the point and the
table definition
BlockReference br = new BlockReference(startPt, bdId);

Then I use two JIGs to get the block insertion point and get the rotation.

I then commit all this to the database within the transaction:

//Use the transaction to commit the changes
tr.AddNewlyCreatedDBObject(ar, true);

How do I get the attribute editor interface to come up???

I tried SendStringToExecute, but cannot figure out how to send the ObjectId of
the BlockReference through:

doc.SendStringToExecute("_eattedit ",false,false,true);
Message 4 of 10
Anonymous
in reply to: Anonymous

I have a command defined:

//Use the wrappers to make an AutoCAD command
[Autodesk.AutoCAD.Runtime.CommandMethod("DLInsert")]
public void DLInsert()

The command is executed by selecting an Icon on a custom toolbar I created in the CUI.

DLInsert checks for an instance of the DeviceInsertFrm class and creates one if necessary.

The user selects the block to insert from a listing on the form.

The Create button on the form calls the insertNewBlock(selectedBlock) method and then that's where the BlockReference is created and the two JIGs are executed.

Control then passes back to the form which I want to leave open so the users can do another insert if they want to.
Message 5 of 10
Anonymous
in reply to: Anonymous

Forget what ChiefBrainFart said, and just download this and
use the Command() method:

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

This will solve both of your problems.

The Command() method waits until the command has
completed before returning, solving the asynchronous
execution problem (code following a call to Command()
does not run until the command has finished).

You can pass ObjectIds directly to the Command()
method when AutoCAD expects an object to be selected:

ObjectId myBlockRefId = ....

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

You can also pass doubles, integers, and Point3d objects
to the Command() method without the need to convert them
to strings.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message
news:6347036@discussion.autodesk.com...
I have a command defined:

//Use the wrappers to make an AutoCAD command
[Autodesk.AutoCAD.Runtime.CommandMethod("DLInsert")]
public void DLInsert()

The command is executed by selecting an Icon on a custom toolbar I created in
the CUI.

DLInsert checks for an instance of the DeviceInsertFrm class and creates one if
necessary.

The user selects the block to insert from a listing on the form.

The Create button on the form calls the insertNewBlock(selectedBlock) method and
then that's where the BlockReference is created and the two JIGs are executed.

Control then passes back to the form which I want to leave open so the users can
do another insert if they want to.
Message 6 of 10
Anonymous
in reply to: Anonymous

Tony,

The filters here block all access to the caddzone.com site so I cannot download the code.
Perhaps you could post it as text?

As for the Chief, he has been very helpful in the past and his input is always welcome.
Message 7 of 10
Anonymous
in reply to: Anonymous

You can email me at the address below if you
need a copy.

{quote}

As for the Chief, he has been very helpful in the past ...

{quote}

Most here, including 'chief' are well-aware of
CommandLine.vb and the fact that it offers the
best possible solution to the problem.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");
Message 8 of 10
Anonymous
in reply to: Anonymous

Hello Tony,

I am trying to use this commandline type you wrote.

 

I downloaded the file and added it to solution.

But I  don't know how to call it.

I don't understand the meanind of follwoing  lines you wrote.

 

You can pass ObjectIds directly to the Command()
method when AutoCAD expects an object to be selected:

ObjectId myBlockRefId = ....

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

 

 

 

Can you help me here please.

 

 

 

 

 

 

Message 9 of 10
Anonymous
in reply to: Anonymous

Tony , This is my Code.

 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
            aa = Entry.ObjectName
            If Entry.ObjectName = "AcDbBlockReference" Then
                TempT = Entry.ObjectID
                CommandLine.Command("_.EATTEDIT", TempT)
            End If
        Next
    End Sub

 Thanks Again.

 

Message 10 of 10
Anonymous
in reply to: Anonymous

Just one other minutely related thought.

ATTREQ = 1  system variable that makes AutoCAD automatically prompt the user when a block that has attributes is inserted.  I've run across many users looking for that feature when it magically got turned off.

 

jvj

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