Author Topic: Change Xref from Attach to Overlay  (Read 3195 times)

0 Members and 1 Guest are viewing this topic.

Murphy

  • Guest
Change Xref from Attach to Overlay
« on: September 19, 2005, 07:56:43 AM »
Is there any way to set the assoc 70 value viw LISP?

I can read it with this:
Code: [Select]
(cdr (assoc 70 (entget xref)))

whdjr

  • Guest
Re: Change Xref from Attach to Overlay
« Reply #1 on: September 19, 2005, 10:20:26 AM »
I am not sure if you could change it via lisp; however if you just want to change one xref then double-click the word 'attach' in the xref manager dialog box and it will change to 'overlay'.(compliments to Randy for that info)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Change Xref from Attach to Overlay
« Reply #2 on: September 19, 2005, 12:17:52 PM »
it might be able to be done via VBA also.  I have never tried but I can look if you want.
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)

Murphy

  • Guest
Re: Change Xref from Attach to Overlay
« Reply #3 on: September 19, 2005, 01:31:51 PM »
I am trying to set an endcommand event routine that will go off after the command 'xref'. I would like it to go through and change all attached xrefs to overlay. We are having problems here with circular references and just thought this would be easier to do than go through and fix it each time. We know who the culprit is so if we set this on their machine it should stop the problems.

Here is what I got from the Autodesk forums
Code: [Select]
VBA Code

Function IsOverlay(XrefName As String, dwg As AcadDocument) As Boolean
Dim blok As AcadBlock
Dim str As String
Dim XrefCode As Long

' *** Default to False
IsOverlay = False

'Set blok = dwg.Blocks(XrefName)

' *** See the XrefName is in the Blocks collection
For Each blok In dwg.Blocks
If StrComp(blok.Name, XrefName, vbTextCompare) = 0 Then
' *** Now see if it's an xref
If blok.IsXRef Then
' *** Now that we have a bonafide xref, pass the name to the
USERS1 AutoCAD user setting
dwg.SetVariable "USERS1", blok.Name
' *** Let the lisp support function do the work
dwg.SendCommand "(getXrefInfo)" & vbCr

' *** Now retrieve the TRUE/FALSE result from USERS1 & if
TRUE, then test the int that was placed in USERI1
str = dwg.GetVariable("USERS1")

If str = "TRUE" Then
XrefCode = dwg.GetVariable("USERI1")
' *** The fourth bit is 1 if it's an overlay (and with 8
to compare)
If XrefCode And 8 Then
IsOverlay = True
End If
End If
End If
End If
Next blok

Set blok = Nothing
End Function


' *** Test function
Sub testOverlay()
Dim ss As AcadSelectionSet
Dim dwg As AcadDocument
Dim blok As AcadBlock
Dim bref As AcadBlockReference

Set dwg = ThisDrawing
Set ss = dwg.ActiveSelectionSet

If SelectObjects(ss) Then
If ss.Item(0).ObjectName = "AcDbBlockReference" Then
Set bref = ss.Item(0)
Set blok = dwg.Blocks(bref.Name)
If blok.IsXRef Then
If IsOverlay(blok.Name, dwg) Then
MsgBox "It's an overlay"
Else
MsgBox "Not an overlay"
End If
End If
End If
End If

Set blok = Nothing
Set bref = Nothing
Set dwg = Nothing
Set ss = Nothing
End Sub

Code: [Select]
LISP Code

; *** Return xref overlay value when given an object handle
(defun getXrefInfo ( / xrefName xref )
(setq xrefName (getvar "USERS1"))
; *** If there is something in the USERI1 variable (integers)
(if (> (strlen xrefName) 0)
(progn
(setq xref (tblobjname "BLOCK" xrefName))
; *** If the xref was found, return the xref info from group 70 via
USERI1 & put TRUE in USERS1
(if xref
(progn
(print (cdr (assoc 70 (entget xref))))
;(print (assoc 70 (entget xref)))
(setvar "USERI1" (cdr (assoc 70 (entget xref))))
(setvar "USERS1" "TRUE")
(print (getvar "USERI1"))
(print (getvar "USERS1"))
)
; *** Else put FALSE in USERS1
(progn
(setvar "USERS1" "FALSE")
)
)
)
; *** Else return FALSE by writing to the USERS1 variable
(progn
(setvar "USERS1" "FALSE")
)
)
)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Change Xref from Attach to Overlay
« Reply #4 on: September 19, 2005, 01:40:20 PM »
I believe the only way to change this programmatically is to detach then reattach

ie read the path, insert etc etc, then 
( vla-Detach ...
( vla-AttachExternalReference ...

or go the (Command ... route

kwb
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.

ronjonp

  • Needs a day job
  • Posts: 7527
Re: Change Xref from Attach to Overlay
« Reply #5 on: September 19, 2005, 01:45:36 PM »
You might want to incorporate (setvar 'xreftype 1) into all of your drafter's startup so at least it would default to overlay.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Murphy

  • Guest
Re: Change Xref from Attach to Overlay
« Reply #6 on: September 19, 2005, 01:49:50 PM »
Ron,

I would if only I were lucky enough to have 2005. Unfortunately I am in 2002.

Kerry,

I thought that might be the case. That is not acceptable to others here so we will have to live with the way things are.

Thank you everyone for your help.

Glenn R

  • Guest
Re: Change Xref from Attach to Overlay
« Reply #7 on: September 19, 2005, 11:34:01 PM »
Also, trying to change the attachment type of an xref that's nested will fail...probably why there isn't a direct API for it.