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

Select bock after insertion

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
SRSDS
397 Views, 4 Replies

Select bock after insertion

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. 

4 REPLIES 4
Message 2 of 5
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 5
SRSDS
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!

Message 4 of 5
Alfred.NESWADBA
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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 5
SRSDS
in reply to: Alfred.NESWADBA

Thanks again!!

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