.NET

Reply
Mentor
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 1 of 5 (144 Views)
Accepted Solution

Select bock after insertion

144 Views, 4 Replies
12-02-2011 12:10 PM

I can't work this out.

 

According to the ADN the only way to insert a block and at the same time update constrained dimensions is to regen: 

 

Application.DocumentManager.MdiActiveDocument.SendStringToExecute("DIMREGEN ", True, False, False)
Application.DocumentManager.MdiActiveDocument.SendStringToExecute("REGEN ", True, False, False)

 

After which I try to retain the selected the block

 

psr = ed.SelectLast
ed.SetImpliedSelection(psr.Value)

 

Is there a way I can force the command(stack) to operate consecutively? For some reason the block selection isn't retained. 

Hi,

 

in the case I need a sendcommand ... and I know it's executed when my current command ended I do the following:

The following is no code, just the structure!

private psr() as ObjectID 'dim the variable
Public sub myMainCommand
psr = ed.SelectLast 'save your selectionset
'BTW I don't know what "SelectLast" in your code is
... do anything
call sendCommand("DIMREGEN" & vbnewline)
... do anything
call sendCommand("DIMREGEN" & vbnewline)
'now the steps you need to get this workaround working
AddHandler for CommandEnded
call sendCommand("myDummyEndCommand")
End sub
Public sub myDummyEndCommand
...this is just to be defined
End sub
EventHandler for CommandEnded:
if CommandName = "myDummyEndCommand" then
RemoveHandler for CommandEnded
...do the jobs like
ed.SetImpliedSelection(psr.Value)
end if

So simplified described:

in your maincommand you place commands onto the comamnd-stack

when your main-command is finished the command-stack sends command by command (so your DIMREGENs or whatever else

and within your mainsub we have defined to run "myDummyEndCommand" as last command

and we have defined an eventhandler watching every single CommendEnded event

so if this handler now catches the command "myDummyEndCommand" the eventhandler knows that way your last command in the main-workflow and can now create a PickfirstSelectionSet/ImpliedSelection.

 

HTH, - alfred -

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 2 of 5 (138 Views)

Re: Select bock after insertion

12-02-2011 12:49 PM in reply to: SRSDS

Hi,

 

don't use SendCommand if you can avoid it. And to do REGEN you can:

Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.Regen

 

- alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 3 of 5 (118 Views)

Re: Select bock after insertion

12-03-2011 01:05 AM in reply to: Alfred.NESWADBA

Hi,

It seems that the advice the ADN gave is currently the only way unfortunately.

I've now thought to restricted the regen SendCommands to only be used when to inserting a dimensioned block.

It will now be unnoticeable.

But I can replace the other SendCommand regens I use with the one you suggested which helps.

 

Thanks again!

*Expert Elite*
Alfred.NESWADBA
Posts: 9,071
Registered: ‎06-29-2007
Message 4 of 5 (114 Views)

Re: Select bock after insertion

12-03-2011 01:48 AM in reply to: SRSDS

Hi,

 

in the case I need a sendcommand ... and I know it's executed when my current command ended I do the following:

The following is no code, just the structure!

private psr() as ObjectID   'dim the variable

Public sub myMainCommand
  psr = ed.SelectLast       'save your selectionset 
                            'BTW I don't know what "SelectLast" in your code is
  ... do anything
  call sendCommand("DIMREGEN" & vbnewline)
  ... do anything
  call sendCommand("DIMREGEN" & vbnewline)

  'now the steps you need to get this workaround working
  AddHandler for CommandEnded
  call sendCommand("myDummyEndCommand")
End sub

Public sub myDummyEndCommand
  ...this is just to be defined
End sub

EventHandler for CommandEnded:
   if CommandName = "myDummyEndCommand" then
      RemoveHandler for CommandEnded
      ...do the jobs like 
      ed.SetImpliedSelection(psr.Value)
   end if

So simplified described:

in your maincommand you place commands onto the comamnd-stack

when your main-command is finished the command-stack sends command by command (so your DIMREGENs or whatever else

and within your mainsub we have defined to run "myDummyEndCommand" as last command

and we have defined an eventhandler watching every single CommendEnded event

so if this handler now catches the command "myDummyEndCommand" the eventhandler knows that way your last command in the main-workflow and can now create a PickfirstSelectionSet/ImpliedSelection.

 

HTH, - alfred -

-------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at
-------------------------------------------------------------------------
Mentor
SRSDS
Posts: 247
Registered: ‎04-15-2011
Message 5 of 5 (99 Views)

Re: Select bock after insertion

12-04-2011 12:30 PM in reply to: Alfred.NESWADBA

Thanks again!!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.