Author Topic: multiple xrefs....  (Read 7731 times)

0 Members and 1 Guest are viewing this topic.

ronjonp

  • Needs a day job
  • Posts: 7531
multiple xrefs....
« on: September 15, 2005, 06:43:35 PM »
Do any of you have a routine to force an xref to be detached even if it exist more than once in a drawing on multiple tabs?

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: multiple xrefs....
« Reply #1 on: September 15, 2005, 06:48:17 PM »
If you erase all instances of an xref, save the drawing, and then re-open it AutoCAD will dump the xref definition all by itself. Of course, one can automate this via lisp /vba too ...
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #2 on: September 15, 2005, 06:56:33 PM »
Michael,

I've been deleting all instances manually and got tired of it.....so you know anyone that could whip up this routine :wink:.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: multiple xrefs....
« Reply #3 on: September 15, 2005, 07:06:49 PM »
Michael,

I've been deleting all instances manually and got tired of it.....so you know anyone that could whip up this routine :wink:.

Ron

Ahhh. Sorry bud, I'm tied up until 10pm +/- and the little bit of grey matter I'll have left after that won't be of much use (not that I'm currently all that coherent). But fear not, lot's of capable hands here ...
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #4 on: September 15, 2005, 07:31:21 PM »
no error control, limited thought, less testing but this should get you.

Code: [Select]
Sub KillDaXwefs()
Dim objWascawyXwef As AcadBlock
Dim objblks As AcadBlocks
Dim intCnt As Integer
Set objblks = ThisDrawing.Blocks
For intCnt = objblks.Count - 1 To 0 Step -1
  Set objblk = objblks(intCnt)
  If objblk.IsXRef Then
    objblk.Detach
  End If
Next intCnt
End Sub

Andrea

  • Water Moccasin
  • Posts: 2372
Re: multiple xrefs....
« Reply #5 on: September 15, 2005, 08:27:22 PM »
simply use....


OVERKILL  command.

 :lol:
Keep smile...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: multiple xrefs....
« Reply #6 on: September 15, 2005, 11:52:32 PM »
Assuming all instances share the same insert point and scale would be folly imo.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: multiple xrefs....
« Reply #7 on: September 15, 2005, 11:53:44 PM »
Assuming all instances share the same insert point and scale would be folly imo.

Isn't that what backups are for ??
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: multiple xrefs....
« Reply #8 on: September 15, 2005, 11:57:42 PM »
Isn't that what backups are for ??

<Jeff Spicolli> Whaaaa? </Jeff Spicolli>
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: multiple xrefs....
« Reply #9 on: September 16, 2005, 12:03:42 AM »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: multiple xrefs....
« Reply #10 on: September 16, 2005, 12:27:53 AM »
lol, touche.

 :-D
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.com • http://cadanalyst.slack.com • http://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #11 on: September 16, 2005, 10:05:58 AM »
Quote
simply use....


OVERKILL  command.
No workie...

Bob,

I get an error with your code "Duplicate Key" on the line     objblk.Detach

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #12 on: September 16, 2005, 11:04:58 AM »
Code: [Select]
Sub KillDaXwefs()
Dim objWascawyXwef As AcadBlock
Dim objblks As AcadBlocks
Dim intCnt As Integer
Dim objSelSet As AcadSelectionSet
Dim objSelSets As AcadSelectionSets
Dim intGroup(0) As Integer
Dim varData(0) As Variant
Dim strSetName As String
Dim objBlkRef As AcadBlockReference

Set objSelSets = ThisDrawing.SelectionSets
strSetName = "LeftInAlbekoikie"
  intGroup(0) = 0: varData(0) = "INSERT"
 
  KillSet strSetName
  Set objSelSet = objSelSets.Add(strSetName)
  objSelSet.Select acSelectionSetAll, , , intGroup, varData

  For Each objBlkRef In objSelSet
    If TypeOf objBlkRef Is AcadExternalReference Then
      objBlkRef.Delete
    End If
  Next objBlkRef
Set objblks = ThisDrawing.Blocks
For intCnt = objblks.Count - 1 To 0 Step -1
  Set objWascawyXwef = objblks(intCnt)
  If objWascawyXwef.IsXRef Then
    objWascawyXwef.Detach
  End If
Next intCnt

End Sub
give this one a shot then

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #13 on: September 16, 2005, 11:19:04 AM »
Now it says sub or function not defined:  KILLSET

hhmmm

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #14 on: September 16, 2005, 11:20:22 AM »
sorry.  Toss this in with it
Code: [Select]
Function KillSet(strSet As String)
  Dim objSelSet As AcadSelectionSet
  Dim objSelSets As AcadSelectionSets
 
  Set objSelSets = ThisDrawing.SelectionSets
     
  For Each objSelSet In objSelSets
    If objSelSet.Name = strSet Then
      ThisDrawing.SelectionSets.Item(strSet).Delete
    Exit For
    End If
  Next

End Function

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #15 on: September 16, 2005, 03:02:41 PM »
Guess by the lack of any additional response it either worked or he gave up.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #16 on: September 16, 2005, 03:26:08 PM »
Bob,

That did work.....cept it detaches all xrefs in the drawing. I need to be able to select which xref to detach.

Thanks for the help.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #17 on: September 16, 2005, 03:28:34 PM »
That would be easy to add.  Did you want to pick one on screen, pick from a list, type in the name, all of the above?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #18 on: September 16, 2005, 03:36:30 PM »
All of the above would be great :). I don't know why AutoCAD doesn't have this functionality out of the box :evil:.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #19 on: September 16, 2005, 03:42:21 PM »
don't have the time or to be truthful the inclination to do it all at least this afternoon.  I will however

a) give you the help you need to make it do all of the above
2) give you one of the above options
or lastly) discuss my rates for completing it per your specs ;)

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #20 on: September 16, 2005, 03:54:14 PM »
The option to select would be good.

As far as compesation goes....you like beer? I'll be in Tucson in May for a wedding. ;-)

Thanks,

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4076
Re: multiple xrefs....
« Reply #21 on: September 16, 2005, 03:55:49 PM »
I'll be in Tucson in May for a wedding. ;-)

Thanks,

Ron
let us know when, as beer is always cold here
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #22 on: September 16, 2005, 05:55:26 PM »
I'm all for the beer.  It's going to have to be Monday though.  That work thing is interfering again.

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #23 on: September 16, 2005, 06:22:04 PM »
I hacked together something that seems to be working alright:

Code: [Select]
;;  Function to detach xref that has multiple references

(defun c:dx (/ ent obj x ss index eobj oname lyr)
 (vl-load-com)
  (while
    (= ent nil)
     (setq ent (car (entsel "\n Select Xref to Detach: ")))
     (if (= ent nil)
       (alert "\n You missed, try again...")
     )
  )
(setq obj (vlax-ename->vla-object ent)
      oname (substr (vla-get-ObjectName Obj)5)
      lyr   (vla-get-Layer Obj)
)
  (if
    (and
      (= (vla-get-ObjectName Obj) "AcDbBlockReference")
      (vlax-property-available-p Obj 'Path)
    )
     (progn
       (setq x    (vlax-get-property obj 'Name)
     ss    (ssget "x" (list (cons '2 x)))
     index -1
       )
       (while (< (setq index (1+ index)) (sslength ss))
(setq obj  (ssname ss index)
       eobj (vlax-ename->vla-object obj)
)
(vla-delete eobj)
       )
     )
     (alert (strcat "\n This program does not work with " oname "s!" "\n" "\n  Please select an Xref."))
  )
  (command "._xref" "D" x)
  (princ (strcat "Xref Name = " x "  --  " (itoa index) " instances deleted and detached.")
  )
  (princ)
)

I won't be there on Monday....we can figure things out.

Cmdr...I'll keep you posted as well. It would be cool to meet some of the "swampers"

Ron
« Last Edit: September 23, 2005, 10:37:15 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Andrea

  • Water Moccasin
  • Posts: 2372
Re: multiple xrefs....
« Reply #24 on: September 17, 2005, 04:38:18 PM »
Quote
simply use....


OVERKILL  command.
No workie...
objblk.Detach

Ron


heun !!?? Working for me... :-o
Keep smile...

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #25 on: September 19, 2005, 01:28:15 PM »
Andrea,

Try this:

Xref a drawing onto one paperspace tab. Copy it and paste on another pspace tab.

Now try to detach it.

You should recieve an error "Xref ... has multiple references. Not detached."

Overkill I believe is to find objects on top of objects and deletes the duplicates, has nothing to do with detaching xrefs.

Ron


Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #26 on: September 22, 2005, 11:57:58 AM »
ronjonp, I let this drop because you got it worked out in lisp.  Are you happy with what you have or do you want to continue with the VBA thingy?

ronjonp

  • Needs a day job
  • Posts: 7531
Re: multiple xrefs....
« Reply #27 on: September 22, 2005, 12:00:13 PM »
This seems to be working out alright. Thanks for checking.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Bob Wahr

  • Guest
Re: multiple xrefs....
« Reply #28 on: September 22, 2005, 12:00:40 PM »
no problem.