Author Topic: Proxy entities  (Read 6132 times)

0 Members and 1 Guest are viewing this topic.

MikeJarosz

  • Guest
Proxy entities
« on: August 29, 2006, 03:45:53 PM »
I posted the following topic on the AUGI programming page. I'm pasting it here in case anyone can shed some light on a tough problem........



"We have a never ending problem with engineering consultants submitting files to us with proxy objects in them, usually from third party software they bought to do their calculations. We have tried everything to persuade them not to send us files with proxies, but nothing stops them. I have decided that a better approach might be to delete the objects on our end.

My first thought was to use a selection filter in VBA to select the proxy objects then delete them. The problem is finding the DXG group code to make the selection. I can't get the codes to work. The proxy notice that pops up on my test file indicates 170 objects. I am able to make a DXF file from this file, and "AcDbProxyObject" appears in the DXF file 170 times. Here's a sample of the DXF code:

0
ACAD_PROXY_OBJECT
5
813D7E
102
{ACAD_REACTORS
330
3859C9
102
}
330
3859C9
100
AcDbProxyObject
90
499
91
937
95
2555929
70
0
93
105
310
4A34D128929A894251896A5A9680
340
813D7F
94
0

I understand what most of this is, but I can't get a selection set that grabs the 170 proxies.Here's my VBA code:


Dim Sset As AcadSelectionSet
Dim Codes(0) As Integer
Dim CodeValues(0) As Variant
Dim Entity As AcadEntity
Codes(0) = 100
CodeValues(0) = "ProxyObject"
Set Sset = ThisDrawing.SelectionSets.Add("Proxy")
Sset.Select acSelectionSetAll, , , Codes, CodeValues
Debug.Print "Drawing  has " & Sset.Count & " proxy entities"

Is this the right approach, or is there some other way to accomplish the task of eliminating proxies?"

Diněsaur

  • Certified Bovine Scat Distributor...I lay it on THICK
  • Needs a day job
  • Posts: 5424
  • But I don't WANT a Day Job
Re: Proxy entities
« Reply #1 on: August 29, 2006, 04:04:04 PM »
I am not sure what proxy objects you are getting, but those generated by LDT and Civil 3D can be exploded into a block and exploded again into native AutoCAD elements.
Stephen R. Sherrill,
The Diněsaur
Civil 3D Specialist Emeritus

YAY ME !!!  I made it out alive !

Jeff_M

  • King Gator
  • Posts: 3946
  • C3D user & customizer
Re: Proxy entities
« Reply #2 on: August 29, 2006, 04:08:45 PM »
First of all, you cannot filter the 100 group codes. Use the 0 group instead. That being said, I'm not so sure you can do anything with the Proxy objects without the object enabler for them. I don't have a Vanilla install here to test on, but you could try Codes(0) = 0 and CodeValues(0) = "*PROXY*"

Of course, If you are going to be sending these drawing back to the consultant, and they are depending on those objects to be there, they may take issue with you deleting them.

Bryco

  • Water Moccasin
  • Posts: 1849
Re: Proxy entities
« Reply #3 on: August 29, 2006, 06:28:23 PM »
Try this on a copy, I'm not quite sure it's what you want and of course there is what Jeff said
Code: [Select]
Sub Apps()
    Dim App As AcadRegisteredApplication
    For Each App In ThisDrawing.RegisteredApplications
        Debug.Print App.Name
        DeleteApplicationXData App.Name
    Next

End Sub



'Cadvault
Public Function DeleteApplicationXData(strAppName As String) As Boolean
    Dim objSelSet As AcadSelectionSet
    Dim objSelCol As AcadSelectionSets
    Dim objEnt As AcadEntity
    Dim intXData(0) As Integer
    Dim varXData(0) As Variant
    Dim varData(0) As Variant
    Dim intData(0) As Integer

    On Error GoTo Err_Control

    Set objSelSet = ThisDrawing.PickfirstSelectionSet
    intData(0) = 1001
    varData(0) = strAppName
    objSelSet.Select 5, FilterType:=intData, FilterData:=varData
    For Each objEnt In objSelSet
        objEnt.SetXData intData, varData
    Next objEnt
    objSelSet.Delete
    DeleteApplicationXData = True

Exit_Here:
    Exit Function

Err_Control:
    Select Case Err.Number
        Case Else
        MsgBox Err.Description
        Resume Exit_Here
    End Select
End Function

Glenn R

  • Water Moccasin
  • Posts: 1932
  • What idiot child of married cousins wrote this?!
Re: Proxy entities
« Reply #4 on: August 30, 2006, 02:11:42 AM »
A selection set will NOT get all proxy objects. Some will live in the land of NOD (named objects dictionary) so you will have to process those as well, but VBA can't from memory.
Me

Arizona

  • Guest
Re: Proxy entities
« Reply #5 on: August 31, 2006, 07:11:46 AM »
I had a similar problem with proxy objects in drawings coming from outside contractors.
I ended up using Microstation to "clean up" these proxy objects.
However I was able to find them using this:

Code: [Select]
Option Explicit

Public Sub Find_Proxy()
  Dim objEnt As AcadEntity
  Dim intCnt As Integer
  Dim iLp As Integer
  Dim iDx As Integer
  Dim objDic As AcadDictionary
  Dim tempObj As AcadObject
  For Each objEnt In ThisDrawing.ModelSpace
    If objEnt.HasExtensionDictionary Then
      objEnt.Color = acRed
      Set objDic = objEnt.GetExtensionDictionary
      iLp = objDic.Count
      For iDx = 0 To iLp - 1
        Set tempObj = objDic.Item(iDx)
        tempObj.Delete
      Next iDx
      intCnt = intCnt + objDic.Count
    End If
  Next objEnt
  Debug.Print intCnt
End Sub

DaveW

  • Guest
Re: Proxy entities
« Reply #6 on: August 31, 2006, 07:19:27 PM »
These are a pain for me too. I just tried both of your's code and they did not work. Like Jeff said!!!

I just had a double fusion in my neck so I am not 100% at the moment. Hopefully someone will figure out a way to get them clean without having the handler.

Funny thing is it says its deleting the Genius MDT stuff, but it is still there in the drawing database viewer. I tried purging and it did no good.

I think the solution code will be exporting out what we want instead of removing what we don't. Even then, who knows?

Chuck Gabriel

  • Guest
Re: Proxy entities
« Reply #7 on: August 31, 2006, 09:09:53 PM »
This might make a good starting point:

Code: [Select]
Option Explicit

Sub main()
  scanDictionary ThisDrawing.Dictionaries
  scanTable ThisDrawing.DimStyles
  scanTable ThisDrawing.Layers
  scanTable ThisDrawing.Linetypes
  scanTable ThisDrawing.TextStyles
  scanObjects
End Sub

Sub scanDictionary(ByRef dictionary As Object)
  Dim obj As AcadObject
  For Each obj In dictionary
    If obj.ObjectName Like "AcDbZombie*" Then
      obj.Delete
    Else
      If obj.HasExtensionDictionary Then
        scanDictionary obj.GetExtensionDictionary
      End If
    End If
  Next obj
  Set obj = Nothing
End Sub

Sub scanTable(ByRef table As Object)
  Dim obj As Object
  For Each obj In table
    If obj.HasExtensionDictionary Then
      scanDictionary obj.GetExtensionDictionary
    End If
  Next obj
  Set obj = Nothing
End Sub

Sub scanObjects()
  Dim block As AcadBlock
  For Each block In ThisDrawing.Blocks
    Dim ent As AcadEntity
    For Each ent In block
      If ent.ObjectName = "AcDbZombieEntity" Then
        ent.Delete
      Else
        If ent.HasExtensionDictionary Then
          scanDictionary ent.GetExtensionDictionary
        End If
      End If
    Next ent
    Set ent = Nothing
  Next block
  Set block = Nothing
End Sub

DaveW

  • Guest
Re: Proxy entities
« Reply #8 on: September 01, 2006, 11:12:16 AM »
Hey Chuck,

I gave your code a walk through on some old MDT proxy stuff.

The line here:
"    If obj.ObjectName Like "AcDbZombie*" Then
      obj.Delete"

This caught this name, "AcDbZombieObject"

Then it refused to delete it with this error (see attached jpg):

Sorry, I could not be more help in fiuring out why it won't delete. AEven at 100% I am only maybe 5% of you guys. ;)

Also, I did bump it down to the next line and it returned:
? obj.HasExtensionDictionary
False


I have attached the drawing if someone wants see this MDT stuff.  I think ADT will be worse.
« Last Edit: September 01, 2006, 11:19:02 AM by DaveW »

Chuck Gabriel

  • Guest
Re: Proxy entities
« Reply #9 on: September 01, 2006, 12:46:58 PM »
When an ObjectARX developer designs a custom object, he gets to decide what operations will be allowed on proxies for that object when his code is not loaded.  Apparently the MDT developers decided to prohibit erasure of MDT proxies (and probably all other operations as well).

I knew this would be a problem for some proxies, but I thought we might get lucky with the particular proxies Mike is confronted with.  Sorry for the wild goose chase.

I believe someone else [edit] err... you I mean [/edit] mentioned exporting everything but the proxies to a new drawing.  That sounds like a pretty good idea to me.  In fact, the code I provided could be adapted to do just that without too much effort.
« Last Edit: September 01, 2006, 02:47:27 PM by Chuck Gabriel »

DaveW

  • Guest
Re: Proxy entities
« Reply #10 on: September 01, 2006, 04:09:11 PM »
It was fun Chuck. It was something important, but not so important, that I could toss around to get my mind off healing. I see your point about how your code can be converted and I may give it a go in few days. I can poke around, but I can't really code right now. It does look pretty simple using your code with an opposite to delete. I know I can get clean 3D solids with an acisout, but most people want some things other than 3D solids. It would be nice to have  free utility for everyone to clean the garbage out.

I really do not agree with giving a programmer the right to decide what you can delete. What is yours is yours. They do that with Macromedia/Adobe Flash. They give the creator of the content the ability to control whether or not you can stop playing the media. Although many reputable sites use this software, many more take advantage of the fact you installed it on a reputable site and now hijack your box with noise and flashing crap everywhere. It should be illegal and I bet it probably is, for both the developers of the custom object that make it undeleteable AND for the content creators that create content that the end user is prohibited from controlling. I really hate to go off on this tangent, but this crap is really pissing me off. On my last purchase of InstallShield I noticed I did not have to provide an uninstaller! Now it may be legal for a software company to give you that option, you do not have that option if you are selling software in the USA and many other countries an uninstaller is required by law.

I wonder if Owen Wengerd has a utility for cleaning this stuff out.

edit: He does. It is thirty bucks. http://www.manusoft.com/Software/SuperPurge/index.stm
Figures!
« Last Edit: September 01, 2006, 04:14:33 PM by DaveW »

DaveW

  • Guest
Re: Proxy entities
« Reply #11 on: September 01, 2006, 04:22:30 PM »
Owen's utility DID work on that drawing. You have to choose hard purge and specifically choose what you want to remove. Choosing all effectively removes everything, as it should. I am going to buy a copy for myself.
« Last Edit: September 01, 2006, 10:08:22 PM by DaveW »

Jeff_M

  • King Gator
  • Posts: 3946
  • C3D user & customizer
Re: Proxy entities
« Reply #12 on: September 01, 2006, 04:48:09 PM »
I purchased Owen's SuperPurge quite some time ago. It works great....mostly. There have been a few drawings that refused to open again after using it, so make sure you always have a valid backup first. And No, I did not report those problems to Owen, as they were on drawings that I really didn't need for much of anything so I just copied out what I did need and called it good.

JohnF

  • Newt
  • Posts: 48
Re: Proxy entities
« Reply #13 on: September 04, 2006, 05:57:14 AM »
Has anyone tried to copy the entities and save them in a new drawing using VBA?

Then saveas to overwrite the drawing with the proxy entities.

That might work every time.

John

Chuck Gabriel

  • Guest
Re: Proxy entities
« Reply #14 on: September 06, 2006, 04:03:32 PM »
Here is another attempt.  It seems to work for me with ADT objects.

Code: [Select]
Sub main()
  Dim sourceDoc As AcadDocument
  Dim targetDoc As AcadDocument
  Set sourceDoc = Application.ActiveDocument
  Set targetDoc = Documents.Add
  scanObjects sourceDoc, targetDoc
  Application.ZoomExtents
  Set targetDoc = Nothing
End Sub

Private Sub scanObjects(ByRef sourceDoc As AcadDocument, _
                        ByRef targetDoc As AcadDocument)
  Dim block As AcadBlock
  For Each block In sourceDoc.Blocks
    If block.IsLayout Then
      Dim index As Long
      Dim objects() As AcadObject
      index = -1
      ReDim objects(0 To block.Count) As AcadObject
      Dim ent As AcadEntity
      For Each ent In block
        If ent.ObjectName <> "AcDbZombieEntity" Then
          If ent.HasExtensionDictionary Then
            scanDictionary ent.GetExtensionDictionary
          End If
          index = index + 1
          Set objects(index) = ent
        End If
      Next ent
      Set ent = Nothing
      If index > -1 Then
        ReDim Preserve objects(index) As AcadObject
        sourceDoc.CopyObjects objects, targetDoc.Blocks(block.Name)
      End If
    End If
  Next block
  Set block = Nothing
End Sub

Sub scanDictionary(ByRef dictionary As AcadDictionary)
  Dim obj As AcadObject
  For Each obj In dictionary
    If TypeOf obj Is AcadDictionary Then
      scanDictionary obj
    ElseIf obj.ObjectName Like "AcDbZombie*" Then
      obj.Delete
    ElseIf obj.HasExtensionDictionary Then
      scanDictionary obj.GetExtensionDictionary
    End If
  Next obj
  Set obj = Nothing
End Sub

This code copies the non-proxy objects to a new drawing.  The new drawing will be left open and unsaved in the editor.