TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Andrea on January 15, 2019, 01:58:14 PM

Title: get PDF with DBX
Post by: Andrea on January 15, 2019, 01:58:14 PM
Hi all,...

I've this code to get PDF with ODBX method.

Code: [Select]
(vlax-for i (vla-get-Layouts dbx)
  (vlax-for Obj (vla-get-Block i)
    (if (and
  (not (member (vla-get-ObjectName obj) '("AcDbViewport")))
  (= (vla-get-ObjectName Obj) "AcDbPdfReference")
  (vlax-property-available-p Obj 'File)
  (setq pdffile (findfile (vla-get-File Obj)))
)
      (setq PdfList (append PdfList (list pdffile)))
    )
  )
)

it work,...but in some case,...it take very long to get the PDF list due the fact the..
Code: [Select]
(vla-get-count (vla-get-Block i)) = 19779
so I'm trying to found a workaround and accelerate the process...
any suggestion ?

Thank you.


Title: Re: get PDF with DBX
Post by: MP on January 15, 2019, 03:58:25 PM
doc
 >> dictionaries
     >> acad_pdfdefinitions
         >> entry
             >> cdr of second 330 group is the instance


And yes, you can get dxf data from dbx docs. Cheers.   
Title: Re: get PDF with DBX
Post by: Andrea on January 15, 2019, 04:43:23 PM
Thank you guys,...

I'll give a try... :)
Title: Re: get PDF with DBX
Post by: kdub_nz on January 15, 2019, 05:00:08 PM

very succinct MP.
Title: Re: get PDF with DBX
Post by: MP on January 15, 2019, 05:23:21 PM
TX
Title: Re: get PDF with DBX
Post by: MP on January 15, 2019, 09:11:18 PM
Quick & dirty - should work but it's been a long day O.o ...

Code: [Select]
(defun _get-pdf-refs ( doc / temp )
    (mapcar 'vlax-ename->vla-object
        (apply 'append
            (mapcar
               '(lambda (x)
                    (mapcar 'cdr
                        (vl-remove-if-not
                           '(lambda (p)
                                (and
                                    (eq 330 (car p))
                                    (eq "PDFUNDERLAY" (cdr (assoc 0 (entget (cdr p)))))
                                )
                            )
                            (entget (vlax-vla-object->ename x))
                        )
                    )
                )
                (progn
                    (vl-catch-all-apply 'eval
                       '((vlax-for x
                            (vla-item (vla-get-dictionaries doc) "acad_pdfdefinitions")
                            (setq temp (cons x temp))
                        ))
                    )
                    (reverse temp)
                )
            )
        )
    )
)

FWIW ... cheers.
Title: Re: get PDF with DBX
Post by: MP on January 16, 2019, 12:57:07 PM
should work ...

Did a quick test; works. Cheers.
Title: Re: get PDF with DBX
Post by: Lee Mac on January 16, 2019, 01:25:11 PM
Code: [Select]
                    (vl-catch-all-apply 'eval
                       '((vlax-for x
                            (vla-item (vla-get-dictionaries doc) "acad_pdfdefinitions")
                            (setq temp (cons x temp))
                        ))
                    )

Neat alternative to (vl-catch-all-apply '(lambda ( ) (vlax-for ... ))) - I like it  :-)
Title: Re: get PDF with DBX
Post by: MP on January 16, 2019, 04:53:23 PM
Thanks Lee. :)
Title: Re: get PDF with DBX
Post by: Andrea on January 18, 2019, 08:59:40 AM
Hi Guys,..

Thanks for the info,...
I'm trying to make test with DBX,..but entget can't be used..
so I still stuck with vla-for each images..

the code actually work,..but i'm trying to improve the speed execution..
any suggestion will be appreciated.
Thank you. :)
Title: Re: get PDF with DBX
Post by: MP on January 18, 2019, 10:36:24 AM
entget can't be used

Explain; I've used entget on dbx docs successfully longer than I've been a member here.
Title: Re: get PDF with DBX
Post by: ronjonp on January 18, 2019, 10:55:12 AM
I think he's referring to this working for IMAGES too.
Title: Re: get PDF with DBX
Post by: MP on January 18, 2019, 11:01:54 AM
Images are just as easy but I'll refrain from posting anything until I understand where the goal posts are. Thanks Ron.