Jump to content

select previous in vba


vivekgrs

Recommended Posts

hi everybody,

i am trying to zoom to the feature which was selected previous using vba. i had tried a lot but i failed. if anyone help me regarding this.

 

i used object.select acselectionsetprevious for this issue. but its not working

 

regards

m.arunachalam

Link to comment
Share on other sites

this is my code

Dim ssEntites As AcadSelectionSet

Set ssEntites = ThisDrawing.SelectionSets.Add("AS_BUILT_PIPE")

ssEntites.Select acSelectionSetprevious

msgbox ssentites.count

Link to comment
Share on other sites

Try something like this:

 

Sub Example_Select()



Dim ssEntites As AcadSelectionSet

  For Each ssEntites In ThisDrawing.SelectionSets
     If ssEntites.Name = "AS_BUILT_PIPE" Then ssEntites.Delete
  Next
  Set ssEntites = ThisDrawing.SelectionSets.Add("AS_BUILT_PIPE")
  ssEntites.Select acSelectionSetPrevious
  MsgBox ssEntites.Count


End Sub

Link to comment
Share on other sites

hi seant,

Thank u for your immediate reply. i had tried ur coding that is also giving the same result.

i had select one entity and run your code. for selecting the entity i had used

ThisDrawing.Utility.GetEntity acent, bpt, "select the line :"

MsgBox ssEntites.Count - it is giving 943.but it wants to give 1.

 

is there any possibility to check which entity is selected in the drawing

 

can u guide me whether im going in correct way or not.

Link to comment
Share on other sites

I have to say that is odd. If you ran the sample I posted (Sub Example_Select()) with either 1 entity currently selected, or only 1 entity having been previously selected, and the MsgBox shows 943 – I can’t even guess why.

 

The problem may be traceable but might require your posting the drawing along with all of your preloaded lisp and VBA routines, which may have reactors running.

Link to comment
Share on other sites

hi seant,

Once again thanks for your help.its working when i had used selectonscreen option for selecting entity.

but i had used

ThisDrawing.Utility.GetEntity acent, bpt, "select the line :"

 

i need one more query

 

is there any possibility to check which entity is selected in the drawing and add in the selectionset

 

thanks

Link to comment
Share on other sites

hi seant,

Once again thanks for your help.its working when i had used selectonscreen option for selecting entity.

but i had used

ThisDrawing.Utility.GetEntity acent, bpt, "select the line :"

 

i need one more query

 

is there any possibility to check which entity is selected in the drawing and add in the selectionset

 

thanks

 

Correct me if I'm wrong but it sounds like you have the original problem figured out.

 

with regard to the last query, the process would be something like this:

 

 

Dim CurrentSSet as As AcadSelectionSet
Dim ExistSSet as As AcadSelectionSet

. . . . . . .

   ' Iterate through  CurrentSSet
   ' Collect the objects found into an array of objects
   ' to be added to the Existing selection set.
   ReDim ssobjs(0 To CurrentSSet.count - 1) As AcadEntity
   Dim I As Integer
   For I = 0 To CurrentSSet.count - 1
       Set ssobjs(I) = CurrentSSet.Item(I)
   Next
   
   ' Add the array of objects to the selection set
   ExistSSet.AddItems ssobjs

. . . . . . .

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...