-KarL- Posted July 23, 2008 Posted July 23, 2008 How do I go about creating a selection set of devices in vba? Thanks in advance KarL Quote
ML0940 Posted July 24, 2008 Posted July 24, 2008 Selection set of devices? Karl, what do you mean by devices? ML Quote
Adesu Posted July 24, 2008 Posted July 24, 2008 Maybe he want like this Sub sss() Dim SS As AcadSelectionSet Set SS = ThisDrawing.SelectionSets.Add("SS") SS.SelectOnScreen Dim Ent As AcadEntity Dim EntName As String For Each Ent In SS EntName = Ent.ObjectName EntName = Mid(EntName, 5, 10) MsgBox "This object selected is = " & EntName Next Ent SS.Delete ' to delete selection set exist End Sub How do I go about creating a selection set of devices in vba? Thanks in advance KarL Quote
-KarL- Posted July 24, 2008 Author Posted July 24, 2008 I have this code that creates a selection set of blocks named SYSNODE Sub getSelectionSet(ssName As String, ssetobj As AcadSelectionSet) On Error Resume Next ThisDrawing.SelectionSets.Item(ssName).Delete On Error GoTo 0 Set ssetobj = ThisDrawing.SelectionSets.Add(ssName) Dim gpCode(1) As Integer Dim dataValue(1) As Variant gpCode(0) = 0 dataValue(0) = "INSERT" gpCode(1) = 2 dataValue(1) = "SYSNODE" ssetobj.Select acSelectionSetAll, , , gpCode, dataValue End Sub I would like to modify it to select devices instead of blocks but I cant firgure out how. Selection set of devices?Karl, what do you mean by devices? ML Not sure how to define them except for smart blocks. For Example, one of the devices we use is a receptacle. It stores all the electrical information of the device (panel, circuit, voltage, amps, wire size, etc.) and then we use tags to display certain information. I think devices are only available in MEP/ABS versions of acad. Quote
ML0940 Posted July 24, 2008 Posted July 24, 2008 Oh, that would explain it then So, they are not block references then; otherwise the other code would work. In The VBAIDE (VBA Environment), if you go to Tools-References, Scroll down, you may see a type library specific to that app. When I was using LDD, there was a type library, specific to those objects. So, if you see a type library for MEP, then check the box, then you should be able to access those objects for programming. When you find out what this object (device) is called in VBA, then you will be able to include it in your code. Then if there is still a problem, we can help you more. ML Quote
-KarL- Posted August 4, 2008 Author Posted August 4, 2008 Ok, I was able to find a work around for devices but does anyone know how to create a selection set of dynamic blocks? Quote
CmdrDuh Posted August 5, 2008 Posted August 5, 2008 I dont have the code handy, but basically create a filter for the blocks Quote
borgunit Posted August 5, 2008 Posted August 5, 2008 You would basically get a selection set of blockrefs and query them by its property .IsDynamicBlock Quote
-KarL- Posted August 5, 2008 Author Posted August 5, 2008 basically create a filter for the blocks That is where I am having problems, I can't figure out how to set up the filters. Quote
CmdrDuh Posted August 5, 2008 Posted August 5, 2008 Set objSelSet = objSelCol.Add("SSName") intType(0) = 0: varData(0) = "INSERT" intType(1) = 2: varData(1) = "BlkName" objSelSet.Select Mode:=acSelectionSetAll, filtertype:=intType, filterdata:=varData Quote
-KarL- Posted August 5, 2008 Author Posted August 5, 2008 varData(0) = "INSERT" I have tried that but it only selects one of the dynamic blocks (the only one I dont need) but not the other 2 dynamic blocks in the drawing. Quote
Olhado_ Posted January 29, 2009 Posted January 29, 2009 Set objSelSet = objSelCol.Add("SSName") intType(0) = 0: varData(0) = "INSERT" intType(1) = 2: varData(1) = "BlkName" objSelSet.Select Mode:=acSelectionSetAll, filtertype:=intType, filterdata:=varData This thread has been very useful; but I have a follow up question. If you have various of block names that you want to include in the filter, do you have to include a corresponding "2" in the Filter Type? In other words, do both the Filter Type and Filter Data arrays have to be of equal size or can one (usually the filter Data) be larger? Thanks. Quote
ML0940 Posted February 6, 2009 Posted February 6, 2009 Olhado, One array can indeed be larger then the other. What "precisely" are you trying to do with the selected blocks? Quote
Olhado_ Posted February 6, 2009 Posted February 6, 2009 Olhado,One array can indeed be larger then the other. What "precisely" are you trying to do with the selected blocks? Thanks for the reply That is good news because now I may not need the communication via "USER" system variables between LISP AND VBA. This is what I am doing right now: Dim LowerLeft As Variant Dim UpperRight As Variant ' Get the Title Block Name defined from LISP routine blkName = Application.ActiveDocument.GetVariable("USERS1") On Error Resume Next ThisDrawing.SelectionSets("GetTitleBlock").Delete If Err.Number > 0 Then Err.Clear Set ssetobj = ThisDrawing.SelectionSets.Add("GetTitleBlock") gpCode(0) = 0 dataValue(0) = "INSERT" gpCode(1) = 2 dataValue(1) = blkName ssetobj.Select Mode:=acSelectionSetAll, FilterType:=gpCode, FilterData:=dataValue For Each acEnt In ssetobj acEnt.GetBoundingBox LowerLeft, UpperRight Next acEnt ReDim Preserve LowerLeft(0 To 1) ReDim Preserve UpperRight(0 To 1) So, according to what you just said I can make "Datavalue" the following: dataValue(1) = "TitleBlock1":dataValue(2) = "TitleBlock2":dataValue(3) = "TitleBlock2": etc I need to do this because I am trying to insert a block on lower right corner of the title block, then print it, and then delete the inserted block. This is to signify that these drawings are final. Quote
ML0940 Posted February 6, 2009 Posted February 6, 2009 You're welcome. I think that I understand what you are trying to do, however, I have a feeling that you are over complicating it a bit. There is no need to use The Users variable, or to have VBA communicate with LISP, in this case. Do you already have an existing LISP routine written that you are trying to tie into The VBA Module? ML Quote
ML0940 Posted February 6, 2009 Posted February 6, 2009 Sorry, I missed this comment.. 'Get the Title Block Name defined from LISP routine blkName = Application.ActiveDocument.GetVariable("USERS1") OK, let's start from the beginning; using VBA, you can insert the block, have the selection set grab the last inserted object, which in this case would be the inserted block, on the lower left on your title block; then we can step into the print part, after we get that part worked out for you. Then, after the print, you can then delete the block from the selection set; then, in the end, we will delete the selection set. If you would like further help, I will need the name of your title block, is it already existing in the drawing? Is the title block at 0,0, and will it remain there? Also, what is the name of the block that you are trying to insert at the lower left of your title block? If we can get that much to work, we can then move onto the printing, and that is where you will prompt the user to pick points. ML Quote
ML0940 Posted March 3, 2009 Posted March 3, 2009 OK, well, I will assume that you are no longer in need of help. Good luck! ML Quote
Olhado_ Posted March 3, 2009 Posted March 3, 2009 Sorry, about not getting back to you; but yeah I think I believe I have a version of the code, in both LISP and VBA. For the record, I cannot just use "last inserted object" because the title block is usually one of the first objects to be inserted. Also, I ended up using VBA to set up the print options only, again mostly because I understand LISP a bit better and was able to find the blocks and boundaries much easier. Thanks for the offer. I am sorry I could not take you up on it. Quote
Recommended Posts
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.