Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbdPowerSet problem

Status
Not open for further replies.

zale86

IS-IT--Management
Dec 17, 2008
9
Im using the vbdPowerSet in a dvb project which collects user input and attribute values and inputs it into a database, then sends an email to certain parties (still finishing that part up). I'm trying to figure out how to modify this to only collect attribute values from the Current Tab. The plan is to prompt the user whether to process just the current tab or all tabs. I don't think I quite understand how the vbdPowerSet function and build filter sub works well enough to make this happen.
Any ideas?
Thanks in advance
 
Hi zale86,

Your question has nothing to do with vbdPowerset, and only a little to do with BuildFilter.

What you're really after are the DXF codes to pass to your selection set.

The first thing you'll need to do, is get the current layout/tab name and save it in a variable.

The next thing you'll need is to build the right "query string" using the correct DXF code:
Code:
Dim curLayoutName As String

curLayoutName = ThisDrawing.ActiveLayout.Name
    
BuildFilter intData, varData, -4, "<and", _
                                  0, "INSERT", _
                                  410, curLayoutName, _
                              -4, "and>"

The next piece you need is "what if they want to process all the layouts?" You can do this one of two ways:
Code:
curLayoutName = "*"
or:
Code:
BuildFilter intData, varData, 0, "INSERT"

Either way will work - your choice.

HTH
Todd
 
Thanks,

I'm currently collecting attributes from only specific blocks from tab:


Set AcadDoc = ThisDrawing ' Current drawing.
BuildFilter intData, varData, -4, "<and", _
0, "INSERT", _
2, "DWG INFON", _
-4, "and>"

How would I add the specific block name to your code:
BuildFilter intData, varData, -4, "<and", _
0, "INSERT", _
410, curLayoutName, _
-4, "and>"

Thanks again for your reply!
D

 
Hi zale86,

Just like you got - just slide it in:
Code:
BuildFilter intData, varData, -4, "<and", _
                                  0, "INSERT", _
                                  [purple][b]2, "DWG INFON", _[/b][/purple]
                                  410, curLayoutName, _
                              -4, "and>"

The whole purpose of BuildFilter is to allow you an easy way to write those long complicated DXF filter codes in a somewhat orderly fashion - here's an example of one I used in another program:
Code:
BuildFilter intData, varData, -4, "<or", _
                                  -4, "<and", _
                                    0, "INSERT", _
                                    -4, "<or", _
                                      70, 0, _
                                      70, 2, _
                                     -4, "or>", _
                                     -4, "<not", _
                                        2, "`*U#*,ADCADD_ZZ", _
                                     -4, "not>", _
                                  -4, "and>", _
                                  -4, "<and", _
                                    2, "`*U#*", _
                                    -4, "*,*,<>", _
                                      10, dblPnt, _
                                  -4, "and>", _
                                -4, "or>"

HTH
Todd
 
Thanks again! That's what I tried before your reply.
There must be more to it than that though. When I insert 410, curLayoutName, _ The routine triggers
MsgBox "The PGS Drawing Information Block wasn't found."

I also tried replacing
curLayoutName = ThisDrawing.ActiveLayout.Name
with
curLayoutName = "100.01" (one of the tabs in my test drawing)

Finally I commented out
If ssTitleBlock.Count = 0 Then
'The title block wasn't found, notify the user and exit.
MsgBox "The PGS Drawing Information Block wasn't found."
End
End If

If ssTitleBlock1.Count = 0 Then
'The title block wasn't found, notify the user and exit.
MsgBox "The Release Block wasn't found."
End
End If

The routine ran, the email was sent, but nothing was written to the database.

 
Hi zale86,

Somewhere in your routine, I think I saw

Code:
Dim AcadDoc
Change it to:
Code:
Dim AcadDoc as AcadDocument
then change this line:
Code:
Set AcadDoc = ThisDrawing.ActiveLayout
to:
Code:
Set AcadDoc = ThisDrawing

Start there and make sure you've dotted all your "i's" and crossed all your "t's" in this regard first - if you don't, I don't know that you'll get all the properties, methods etc you need for the routine to work.

You didn't mention what version of AutoCAD your using, I've some issues with this not working on older versions of AutoCAD - I pretty sure the 410 code worked with at least 2004.

HTH
Todd
 
Todd,
Tried it with the same result. If I just remove
410, curLayoutName, _
It runs perfectly.

I also tried using UserS1 instead of curLayoutName just in case it wasn't getting the current tab for some reason. That variable represents the current tab passed from the lisp routine I'm using to gather info and call up addrelease.dvb.

I'm running AutoCAD 2008.

Thanks,
David
 
Hi David,

I couldn't run the LISP routine it just errored out - it's been too long since I've done any LISP to fix it...

But, I did set USERI4 to 1 and then ran the ExportAttribsReleases macro and it did exactly as it was supposed to. I also added a couple of blocks and renamed them to your block names in the routine and they worked.

Have you tried it this way, I did notice your not checking for any blank/empty conditions when checking for USERIn. Not sure if that's the problem or not, and the other issue is I'm running 2009, I don't recall if there were any issues like you're having with 2008 but I doubt it. You might try adding/substituting this little snipet and then run it from VBAIDE and see if you get anything back:
Code:
' Was anything actually found?
    '
    If ssTitleBlock.Count = 0 Then
      'The title block wasn't found, notify the user and exit.
      MsgBox "The PGS Drawing Information Block wasn't found."
      End
    [b][red]Else
      Debug.Print "ssTitleBlock has " & ssTitleBlock.Count & " entities in it."
      Debug.Print ssTitleBlock.Item(0).Name
      Debug.Print "curLayoutName was " & curLayoutName  
    End If
    
    If ssTitleBlock1.Count = 0 Then
      'The title block wasn't found, notify the user and exit.
      MsgBox "The Release Block wasn't found."
      End
    Else
      Debug.Print "ssTitleBlock1 has " & ssTitleBlock1.Count & " entities in it."
      Debug.Print ssTitleBlock1.Item(0).Name
      Debug.Print "curLayoutName was " & curLayoutName
    End If
        
    End[/red][/b]

At least you'll get a better idea where it's breaking.

HTH
Todd
 
Ok,
I inserted your error trapping and still got the same msgbox result which would indicate that no blocks were detected.
I removed 410, curLayoutName, _
from
ElseIf UserI4 = "2" Then
BuildFilter intData1, varData1, -4, "<and", _
0, "INSERT", _
2, "Release2", _
410, curLayoutName, _
-4, "and>"

and it ran, but along with returning the values of current tab, and block name, it returned the count which was incorrect- it's getting the count from both tabs in this drawing instead of only from the current tab. So this must have to do with the selection set?
 
Hi David,

Now I'm wondering if it's something in your drawing, maybe a tab name, or the blocks themselves - these aren't xrefed in by any chance are they?

When I tested your routine I had inserted the blocks, not xrefed them, and had three tabs "Model", "Work", and "Work (2)".

I'm heading out to the airport shortly maybe you can post a drawing and I can try it with your drawing, probably won't be until Monday though...
 
You bet.
Posted is
I posted a drawing which has two tabs (its a mess because I'm in the process of changing the title block and some other things), my database (access), my "real" lisp routine and one called test which I've been using to quickly pass limited info to the dvb.
I'm thrilled that you are willing to help me out!
Have a good weekend.
David
 
Hi zale86,

Hope your weekend was good.

I took a look at your routine and it seems to be working, with the exception of this addtion/clean up I did to your ExportAttribsReleases routine:

Code:
  ' Defaults.
  '
  Set AcadDoc = ThisDrawing ' Current drawing.
  
  UserI4 = AcadDoc.GetVariable("UserI4")
  UserS1 = AcadDoc.GetVariable("UserS1")

  If UserS1 = "ALL" Then
    curLayoutName = "*"
  Else
    curLayoutName = AcadDoc.ActiveLayout.Name
  End If

I loaded both the release.lsp and the test.lsp but only ran the test.lsp routine. I was prompted for either (O)ne or (A)ll. If I typed "o", I got the current sheet information placed into the release table of the database. If I type "A", I got all the sheets' information in release table.

Maybe you just need to make these changes and it will work, I'm not sure at this point. The next issue might be whether or not you have all the service packs for AutoCAD installed or not. Also, just for grins, have you tried it on a different machine?

HTH
Todd
 
Drat!
If I comment out the MSG BOX statements and run test.lsp I get:
ssTitleBlock has 0 entities in it.
ssTitleBlock has 0 entities in it.
curLayoutName was 100.01
ssTitleBlock1 has 0 entities in it.
curLayoutName was 100.01
In the Immediate pane.

Else If I don't comment out, I just get the message box. If I remove "410, curLayoutName, _" it runs and enters both sheets into the database. I have installed service pack one but have not installed the mirriad of hot fixes. Haven't had a chance to try it on another machine yet. I'll try that next I guess.
Seems so odd that the blocks are percieved unless the filter is applied. Makes me think it's something not right with either vbdPowerSet or BuildFilter, but that is probably my ignorrance!
I'm here today and tomorrow and then will be off for two weeks to Guyana and then Tobago for some fun! Hope I can crack it before then but if not it will be waiting when I get back. Thanks so much for your help.
David
 
Hi David,

This has been bugging me so I went over to the Autodesk forum and found a few posts with your problem, check out this post: scroll down to post 138, if it doesn't take you there directly, you're not the only one with this issue. The problem is the 410 code in the filters. There are more than a few threads on this and they offer some work arounds.

HTH
Todd
 
Well,
It doesn't work on any 2008 machine here, but does work with 2009. Were you using 2009 as well? I'm not happy with the performance of 2009 but it looks like I'm going to have to roll it out to at lease a couple of users....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top