3 Replies Latest reply on Feb 14, 2012 9:51 AM by BoarderGrl

    pcbDoc.PlacementObstructs

    BoarderGrl

      I am trying to get the height of placement obstructs from the top and bottom layers. Here is the code I am trying to use:

       

      If (ValidateServer(pcbDoc) = 1) Then

          Dim PHfso, PHf1, PHdesignName, PHtoppo, PHbotpo, PHpob, PHside, PHlayct

          PHlayct = pcbDoc.LayerCount

          Set PHpob = pcbDoc.PlacementObstructs(epcbSelectAll,0)

          PHpob.Sort

      'msgbox ("layer count is: " & PHlayct)     'just to make sure it works and it does

          Set PHside = PHpob.Layer

          msgbox PHside

          If Phlayct = PHpob.Layer Then

              PHbotpo = PHpob.Height

          ElseIf PHpob.Layer = 1 Then

              PHtoppo = PHpob.Height

          End If  

       

      This is the part I am having a problem with, so I didn't include the rest of the code below this. I am getting a VBscript runtime error of "Object doesn't support this property or method, 'Layer'", and points to "Set PHside = PHpob.Layer Then". According to the Automation help, placementobstructs is a property of the active document, pcbDoc in this case, and .Layer is a property of placementobscructs. So I don't know why I am getting this error.

       

      Any ideas?

      Thanks,

      Andrea

        • 1. Re: pcbDoc.PlacementObstructs
          matthias.cosaert

          Set PHpob = pcbDoc.PlacementObstructs(epcbSelectAll,0) returns a collection of placement obstructs so you should use a for each loop to get the actual placement obstructs.

           

           

          If (ValidateServer(pcbDoc) = 1) Then

              Dim PHfso, PHf1, PHdesignName, PHtoppo, PHbotpo, PHpob, PHside, PHlayct

              PHlayct = pcbDoc.LayerCount

              Set PHpobColl = pcbDoc.PlacementObstructs(epcbSelectAll,0)

              PHpobCol.Sort

          'msgbox ("layer count is: " & PHlayct)     'just to make sure it works and it does

          for each PoObj in PHpobColl

              PHside = PoObj.Layer

              msgbox PHside

              If Phlayct = PoObj.Layer Then

                  PHbotpo =PoObj.Height

              ElseIf PoObj.Layer = 1 Then

                  PHtoppo = PoObj.Height

              End If 

          ...

          next

          • 2. Re: pcbDoc.PlacementObstructs
            john_dube

            The error is because you used the Set statement with a variable (not an object) assignment.

             

            The Layer property is a number, so the Set statement is not required.

             

            Change this:

             

                 Set PHside = PHpob.Layer

             

            to this:

             

                 PHside = PHpob.Layer

             

            and your script should work.

             

            John

            • 3. Re: pcbDoc.PlacementObstructs
              BoarderGrl

              I added the For Each code to go through all of the placement obstructs. After looping through and getting a 1 then another 1, then another, then 14, another 14, something else was going on. I added a count to the collection to find out how many placementobstructs are on the document, I got 34. 12 on layer 1 and 22 on layer 14.

               

              So I had to modify your code to find only the obsctruct that had a height greater than 0. So I added an AND.

               

              This is what I did.

               

                  If Phlayct = PHpob.Layer And PHpob.Height > 0 Then

                      PHbotpo = PHpob.Height

                      msgbox PHbotpo 'just to see if it works

                  ElseIf PHpob.Layer = 1 And PHpob.Height > 0 Then

                      PHtoppo = PHpob.Height

                      msgbox PHtoppo 'just to see if it works

                  End If  

               

              I am not sure what I will do if I have more than 1 obstruct on layer 1 with a height of 0. My guess is that it will just spit out the first obstruct with a height greater than 0.