Author Topic: List of Xref in Dwgprops Comments Area  (Read 1634 times)

0 Members and 1 Guest are viewing this topic.

jaydee

  • Guest
List of Xref in Dwgprops Comments Area
« on: July 05, 2011, 09:34:07 AM »
Hi.
I got these codes from this forum either from Ronjonp/T.willey/joe Burke
which returns a list of xref in a list

(defun xrefnamelist (/ #list)
  (vlax-for i (vla-get-filedependencies (vla-get-activedocument (vlax-get-acad-object))) ;_ vla-get-FileDependencies
    (if (= (vla-get-feature i) "Acad:XRef")
      (setq #list (cons (vl-filename-base (vla-get-filename i)) #list)) ;_ setq
    ) ;_ if
  ) ;_ vlax-for
  (acad_strlsort #list)
) ;_ defun


How can i seperate the list and format it so it could be written to dwgprops comments areas.
or format each xref name separated by "\r\n" so each xref is list under the other in a column style
ie
(vla-put-comments si    (strcat "\nXrefs:  " xref1 "\r\n" xref2 "\r\n" xref3 "\r\n"xref4  "\r\n" etc. etc))

drawing properties summary tab comment:
Xrefs:
REFERENCE DRAWING 1
REFERENCE DRAWING 2
REFERENCE DRAWING 3
REFERENCE DRAWING 4
etc.


Thankyou



irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List of Xref in Dwgprops Comments Area
« Reply #1 on: July 05, 2011, 09:46:42 AM »
You can do that in several ways, perhaps:
Code: [Select]
(setq str "")
(foreach xref (xrefnamelist)
  (setq str (strcat str "\n\r" xref))
)
(vla-put-comments si (strcat "\nXrefs: (vl-string-trim "\n\r" str)))

Edit, if you want to keep the new-line before the list, just omit that vl-string-trim function. It's unclear how you prefer it, since the code you've got would show the 1st xref on the 1st line, but your example shows it on the 2nd line.
« Last Edit: July 05, 2011, 09:49:52 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List of Xref in Dwgprops Comments Area
« Reply #2 on: July 05, 2011, 09:53:09 AM »
Probably the "most" lisplike and "elegant" way would be something like this:
Code: [Select]
(vla-put-comments si
  (apply 'strcat (cons "Xrefs:" (mapcar '(lambda (str) (strcat "\r\n" str)) (xrefnamelist))))
)
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

jaydee

  • Guest
Re: List of Xref in Dwgprops Comments Area
« Reply #3 on: July 05, 2011, 10:44:47 AM »
thankyou Irneb
both codes works the way i wanted it and mod it slightly and should have been "\r\n"

(foreach xref (xrefnamelist)
  (setq str (strcat str "\n\r" xref))
)
(vla-put-comments si (strcat "Xrefs:  " str))

Cheers


irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: List of Xref in Dwgprops Comments Area
« Reply #4 on: July 05, 2011, 11:18:15 AM »
You're welcome!

Sorry about the wrong order of return & newline, couldn't remember what was the "correct" way round.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.