Author Topic: get xref path  (Read 8361 times)

0 Members and 1 Guest are viewing this topic.

danny

  • Guest
get xref path
« on: May 04, 2005, 07:59:56 PM »
need some help or direction
trying to find a way to get the path of a selected xref?
thanks...

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
get xref path
« Reply #1 on: May 04, 2005, 08:46:22 PM »
Have a look at this fine piece of work by MP.
http://www.theswamp.org/phpBB2/viewtopic.php?t=3816
TheSwamp.org  (serving the CAD community since 2003)

danny

  • Guest
get xref path
« Reply #2 on: May 04, 2005, 08:58:41 PM »
Thanks Mark, MP
I'll take a look at it.

pmvliet

  • Guest
get xref path
« Reply #3 on: May 05, 2005, 10:58:45 AM »
Not sure what you are looking for, but keep Reference manager in mind. It has some kewl things and also lets you move path's of referenced items.

for 2k2 it is in the extensions, for 2k4 and above it is installed with the program.

Pieter

danny

  • Guest
get xref path
« Reply #4 on: May 11, 2005, 11:10:43 PM »
Mark/MP or anyone else,
I've taken a look at MP's function and I'm trying to disect it to find exactly what I need, but all I've gotten so far is a headache.
What I'm trying to do is create a lisp that will open a selected xref file.  In order to do that i have to get its path.  File size, Flags, or Count is not needed.
I do use refedit, but in some cases an actual opening of the file is neccessary.

nivuahc

  • Guest
get xref path
« Reply #5 on: May 12, 2005, 12:10:57 AM »
Have you tried the XOPEN command?

whdjr

  • Guest
get xref path
« Reply #6 on: May 12, 2005, 08:24:54 AM »
Code: [Select]
(defun *ssnames* (selection_set / num lst)
  (repeat (setq num (sslength selection_set))
    (setq num (1- num)
 lst (cons (ssname selection_set num) lst)
    )
  )
  lst
)

(defun *dxf* (gcode elist)
  (cdr (assoc gcode elist))
)

(defun remove2 (ss)
  (vl-remove-if-not
    '(lambda (x)
       (= (logand (*dxf* 70
(entget
  (tblobjname "block" (*dxf* 2 (entget x)))
)
 )
 4
 )
 4
       )
     )
    ss
  )
)

(defun c:xref_tools (str / sel len obj path pos name ent)
  (setq sel (ssget '((0 . "INSERT"))))
  (if sel
    (and (setq sel (*ssnames* sel))
(setq sel (remove2 sel))
(foreach ent sel
  (setq ent (entget (tblobjname "block" (*dxf* 2 (entget ent)))))
  (setq path (*dxf* 1 ent))
  (cond ((eq str "open")
 (command "vbastmt"
  (strcat "AcadApplication.Documents.Open \""
  path
  "\""
  )
 )
)
(T
 (setq pos  (vl-string-position 92 path nil T)
name (substr path (+ 2 pos))
pos  (vl-string-position 46 name 0)
name (substr name 1 pos)
 )
 (command "_xref" str name)
)
  )
)
    )
  )
  (princ)
)
Put all this in the same file.  Load it.

Usage:

(c:xref_tools "open")  ---> Opens the selected xrefs.
(c:xref_tools "reload")  ---> Reloads the selected xrefs.
(c:xref_tools "detach")  ---> Detaches the selected xrefs.

**disclaimer** --> These were written and tested for AutoCAD 2000.

Hope this helps,

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
get xref path
« Reply #7 on: May 12, 2005, 08:46:29 AM »
Quote from: danny
Mark/MP or anyone else,
I've taken a look at MP's function and I'm trying to disect it to find exactly what I need, but all I've gotten so far is a headache.
What I'm trying to do is create a lisp that will open a selected xref file.  In order to do that i have to get its path.  File size, Flags, or Count is not needed.
I do use refedit, but in some cases an actual opening of the file is neccessary.

Disect it?

Maybe you can better define what mean "The path of a selected xref". How are you selecting it?

But to push forward with an attempt to help (as questionable as that may be before my first coffee) ...

If you load up my utility you might call / invoke it like this:

Code: [Select]
(GetXrefsProperties
    (vla-get-activedocument
        (vlax-get-acad-object)
    )
)

It might return the following data --

Code: [Select]
(   (   "Taisei Detail Plan"
        "C:\\ACAD2006\\SAMPLE\\TAISEI DETAIL PLAN.DWG"
        44
        1
    )
    (   "Taisei Door Window Sheet"
        "C:\\ACAD2006\\SAMPLE\\TAISEI DOOR WINDOW SHEET.DWG"
        44
        1
    )
    (   "Taisei Interior Elv"
        "C:\\ACAD2006\\SAMPLE\\TAISEI INTERIOR ELV.DWG"
        44
        1
    )
)

There are 3 items in the list. Each Item is also a list itself. The first item is the xref name, the second the path, the third the flags* values, and finally the forth is the tally of the number of instances of said xref (normally 1).

So, let's say I "picked" the xref "Taisei Detail Plan" and I wanted the path for it:

Code: [Select]
(cadr
    (assoc
        "Taisei Detail Plan"
        (GetXrefsProperties
            (vla-get-activedocument
                (vlax-get-acad-object)
            )
        )
    )
)

=> "C:\\ACAD2006\\SAMPLE\\TAISEI DETAIL PLAN.DWG"

Hope this helps.

:)

*Flags is the bitcoded value associated w/dxf group 70, please see the dxf reference.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

nivuahc

  • Guest
get xref path
« Reply #8 on: May 12, 2005, 09:53:33 AM »
Code: [Select]

(vlax-get-property (vlax-ename->vla-object (car (entsel "\nSelect XREF: "))) 'Path)

nivuahc

  • Guest
get xref path
« Reply #9 on: May 12, 2005, 10:03:07 AM »
Don't have the XOPEN command? That's okay, using the technique in Will's code and the above, here's one that works just fine in AutoCAD 2002 (no error checking)
Code: [Select]

(defun C:XOPEN (/)
  (vl-load-com)
  (command "vbastmt"
  (strcat "AcadApplication.Documents.Open \""
  (vlax-get-property
    (vlax-ename->vla-object (car (entsel "Select XREF for Editing: ")))
    'Path
  )
  "\""
  )
  )
)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
get xref path
« Reply #10 on: May 12, 2005, 11:02:25 AM »
Ok, Mr. Slow guy here. :roll:

Given this --

Code: [Select]
(defun GetXrefPath ( ename / object )
    (cond
        (   (and
                (eq 'ename (type ename))
                (eq "AcDbBlockReference"
                    (vla-get-objectname
                        (setq object
                            (vlax-ename->vla-object
                                ename
                            )
                        )
                    )    
                )
                (vlax-property-available-p object 'path)
            )
            (vla-get-path object)
        )    
    )
)

Try this --

Code: [Select]
(defun c:XOpen ( / path )
    (if (setq path (GetXrefPath (car (entsel))))
        (if (zerop (getvar "sdi"))
            (vla-open
                (vla-get-documents (vlax-get-acad-object))
                path
            )
            (vla-sendcommand
                (vla-get-activedocument (vlax-get-acad-object))
                (strcat ".open " path "\n")
            )
        )
    )    
    (princ)    
)

Cheers.

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

nivuahc

  • Guest
get xref path
« Reply #11 on: May 12, 2005, 11:22:14 AM »
:P

danny

  • Guest
get xref path
« Reply #12 on: May 12, 2005, 02:07:08 PM »
sorry guys,
I think you all wake up a lot earlier than me..
Quote
Have you tried the XOPEN command

no, I didn't know that was available.  :oops:

Quote
(GetXrefsProperties
    (vla-get-activedocument
        (vlax-get-acad-object)
    )
)

This was what a was trying to work with and I can see now, from your routines, how it works.
Thanks for helping me understand.
Hopefully I can krank this stuff out by myself one day...

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
get xref path
« Reply #13 on: May 12, 2005, 03:06:45 PM »
Our pleasure, come back when you're plate empties.

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

danny

  • Guest
get xref path
« Reply #14 on: May 17, 2005, 05:29:57 AM »
o.k, my plates empty...or should I say full, I just don't know how to use my utensils to eat.
I was using the xopen to rename some bad filenames but completing the task at hand has become  quite a burden..  I have 150 sheets and I need to find out what xrefs are in the sheets, and rename them.  I've been looking around and found a clip from Smadsen.http://www.theswamp.org/phpBB2/viewtopic.php?t=3083&highlight=xref
got some really long file names that need to be simplified.  I would post some of them but I'm at home right now.  But their way past 30 characters long and its driving me insane.  I know I can change the path using reference manager, but the name?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
get xref path
« Reply #15 on: May 17, 2005, 07:59:56 AM »
Slowly double click the name whilest in xref manager it, will let you edit the name.

Alternatively, one could come up with some kind of scheme to do it automagically, even something simple like xref01, xref02 ... xref30 has to be better than --

IMP-DrawingSheet-yada-yada-yada-PLANDETAIL(BLDGCESCALATORUP-LEVEL1TO2).dwg

But what I suggest is that you create a little lookup table. For every one of these xrefs with the masochist designed file name, create an alias -- the alias will be used as the xref name in parent drawings. Once you finish the lookup table we could write a simple little function to cycle thru the document's, doing a search and replace on the names.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

danny

  • Guest
get xref path
« Reply #16 on: May 17, 2005, 04:16:47 PM »
So a table that has
Quote
Long a$$ name  =  name
Lnog a$$ name  = name
Long a$$ name  =  name

I'll work on it..

danny

  • Guest
get xref path
« Reply #17 on: May 18, 2005, 07:49:21 PM »
okay,
I made a list of the drawing, sheets and xrefs.  The previous designer on this project used Revit.  I beleive Revit isn't to friendly after exporting info to dwg.  I've got xref files that don't have anything in it but a couple of lines, but yet the sheet that its xrefed in is showing an intire floor plan comming from this file.  All layers on, thawed, but only two lines in the xref dwg.  Some wierd things going on.  I thinking I gonna have to bind everthing to the sheets then create xref files from there.  Any Ideas?
If you want to take a look, the excel sheet of file names is in the lilly pond under \danny.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
get xref path
« Reply #18 on: May 18, 2005, 10:10:54 PM »
I don't have excel installed here yet, any chance you can export to a csv (comma separated values)  file? Thanks.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

danny

  • Guest
get xref path
« Reply #19 on: May 18, 2005, 10:31:26 PM »
done..

danny

  • Guest
get xref path
« Reply #20 on: May 18, 2005, 10:57:47 PM »
looking at the list I can see that revit exploded everthing into its own files.  Example, Building A Floor 1 has 7 xrefs of the site.  Where as it should be 1 xref.  Building B Floor 1, Same site, has 6 xrefs of the site, and their all their own files.  Should be 1. :shock:

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
get xref path
« Reply #21 on: May 19, 2005, 07:25:26 AM »
Danny, why did you provide aliases for some drawings and not others? Also, the data is inconsistant: sometimes the full path and the alias is separated by one comma, other times 2. Makes it more onerous for a program to process than is necessary.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

danny

  • Guest
get xref path
« Reply #22 on: May 19, 2005, 03:46:08 PM »
Quote
Danny, why did you provide aliases for some drawings and not others?
I've located what sheets the xrefs belong to.  As far as renaming them, I am now finding out that they are all bits and pieces of an overall.  So lets say sheet AA-101 has these xrefs in them
Code: [Select]
IMP-DrawingSheet-AA-101-BUILDINGALEVEL1FLOORPLAN-FloorPlan-A-1.dwg
IMP-DrawingSheet-AA-101-BUILDINGALEVEL1FLOORPLAN-IMPSiteandStream.rvt-1.dwg
IMP-DrawingSheet-AA-101-BUILDINGALEVEL1FLOORPLAN-PrincessKaiulani.rvt-1.dwg
the xrefs that has the "IMPSiteandStream" is pieces of the IMP-DrawingSheet-AS-101-OVERALLARCHITECTURALSITEPLAN-IMPSiteandStream.rvt-1.dwg
.  An xref that is in sheet AS-101.
Quote
Also, the data is inconsistant: sometimes the full path and the alias is separated by one comma, other times 2
The full path came from Revit.  
Quote
Makes it more onerous for a program to process than is necessary
I'm realizing this.  Your help with the xopen and finding xref paths and info has been very helpful.  At this point, I may have to go into every sheet to put together this puzzle.  What makes things worse, the base points of all the xrefs are inconsistant as well. :x
Thanks for your help MP, I really do appreciate it.