modify PDFUNDERLAY properties

modify PDFUNDERLAY properties

_anonandon
Advocate Advocate
841 Views
15 Replies
Message 1 of 16

modify PDFUNDERLAY properties

_anonandon
Advocate
Advocate

I've got multiple pdf underlays to clip, all the same (to remove a border).

 

I see that the clipping boundary is defined as two points relative to the insertion point of the object so could someone point me in the right direction how to modify all the underlays?

 

(-1 . <Entity name: 1ab0252f740>)
(0 . "PDFUNDERLAY")
(330 . <Entity name: 1ab3aa869f0>)
(5 . "6133E74")
(100 . "AcDbEntity")
(67 . 0)
(410 . "Model")
(8 . "_ELEC1")
(100 . "AcDbUnderlayReference")
(340 . <Entity name: 1ab0252f6e0>)
(10 618771.0 308239.0 0.0)
(41 . 12.702)
(42 . 12.702)
(43 . 12.702)
(50 . 0.0)
(210 0.0 0.0 1.0)
(280 . 11)
(281 . 100)
(282 . 0)
(11 0.25 11.5278 0.0)
(11 16.243 2.5009 0.0)

0 Likes
Accepted solutions (2)
842 Views
15 Replies
Replies (15)
Message 2 of 16

Moshe-A
Mentor
Mentor

@_anonandon hi,

 

Looks like you are right, the 2 clipping points are referencing the pdfunderlay insertion point. the first (dxf11) is the upper left of the clipping boundary and the second (dxf11) is the lower right.

 

Moshe

Message 3 of 16

_anonandon
Advocate
Advocate

thanks for the support!

my beginner lisp wont allow me to modify all of the underlays with the same clipping points, any advice welcome......

0 Likes
Message 4 of 16

Moshe-A
Mentor
Mentor

post a sample dwg

0 Likes
Message 5 of 16

_anonandon
Advocate
Advocate

done

0 Likes
Message 6 of 16

_anonandon
Advocate
Advocate

how about:

0 Likes
Message 7 of 16

Moshe-A
Mentor
Mentor

@_anonandon 

 

How the sample dwg helps without the pdf?

 

you said you have multiple pdf underlays and you want to reset the clipping boundary differently in each one then how automation is useful?

you want to step each pdf and specify it's clipping boundary?

 

Moshe

 

 

 

0 Likes
Message 8 of 16

_anonandon
Advocate
Advocate

the pdf.....

 

I want all pdf's clipped the same. 

0 Likes
Message 9 of 16

Moshe-A
Mentor
Mentor
Accepted solution

@_anonandon  hi,

 

check MPDFCLP command

 

enjoy

Moshe

 

(defun c:mpdfclp (/ _swapVar ; local function
		     p0 p1 p2 p3 p4 p5 p6 ss ctr ename elist)

 (defun _swapVar (Qa0 Qa1 / tmp)
  (setq tmp (vl-symbol-value Qa0))
  (set  Qa0 (vl-symbol-value Qa1))
  (set  Qa1 tmp)
 ); _swapVar

 (setvar "cmdecho" 0)
 (command "._undo" "_begin")
  
 (if (and
       (setq p1 (getpoint "\nSpecify first corner point: "))
       (setq p2 (getcorner p1 "\nSpecify opposite corner point: "))
       (setq ss (ssget '((0 . "pdfunderlay"))))
     )
  (progn
   (setq ctr 0)
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
    (setq ctr (1+ ctr))
    (setq elist (entget ename))
    (setq p0 (cdr (assoc '10 elist)))
    (command "._pdfclip" ename "_delete") ; remove existing clip if exist

    (if (< (car p2) (car p1))
     (_swapVar 'p1 'p2)
    )

    (if (> (cadr p2) (cadr p1))
     (_swapVar 'p1 'p2)
    )

    (if (= ctr 1)
     (setq p3 (mapcar '- p1 p0) p4 (mapcar '- p2 p0))
    )

    (setq p5 (mapcar '+ p0 p3))
    (setq p6 (mapcar '+ p0 p4))
    
    (command "._pdfclip" ename "_New" "_Rectangular" p5 p6)
   ); progn
  ); foreach
 ); if

 (command "._undo" "_end")
 (setvar "cmdecho" 1)

 (princ)
)
Message 10 of 16

Moshe-A
Mentor
Mentor

@_anonandon ,

 

made update, use the last version

 

 

0 Likes
Message 11 of 16

_anonandon
Advocate
Advocate

very cool!!

0 Likes
Message 12 of 16

_anonandon
Advocate
Advocate

@Moshe-A wrote:

@_anonandon ,

 

made update, use the last version

 

 


Useful. FYI I have noticed a couple of things (I can work around them no problem):

 

The clipping boundary corners P1 and P2 must be on the first PDF that is selected ??is this because of PDF order in ssget list??

is it necessary to calculate the absolute x,y of the clip?

 

something is strange with osnap and PDFs!

(depending how they've been created some of the pdf's i use have frames that are snappable)

if i use your lisp as above and snap to a frame then the clipping boundary is often in the wrong place.

 

if i modify the lisp so that ssget is before P1/P2 and zoom in a lot to snap the clipping boundary is usually in the correct place.

 

is i turn off osnap the clip is always correct.

??could position accuracy of a pdfunderlay vary with zoom level??

 

(defun c:mpdfclp (/ oldsnap p0 p1 p2 p3 p4 p5 p6 ss ctr ename elist)

 (setvar "cmdecho" 0)
 (command "._undo" "_begin")

 ;(setq oldsnap (getvar "osmode"))
 ;(setvar "osmode" 0)
  
 (if (and
       (princ "\n<<<< Select FIRST PDF then the others >>>>")
       (setq ss (ssget '((0 . "pdfunderlay"))))
       (setq p1 (getpoint "\nZOOM IN. Specify first corner point of first PDF: "))
       (setq p2 (getcorner p1 "\nZOOM IN. Specify opposite corner point of first PDF: "))
     )
  (progn
   (setq ctr 0)
   (foreach ename (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
    (setq ctr (1+ ctr))
    (setq elist (entget ename))
    (setq p0 (cdr (assoc '10 elist)))
    (command "._pdfclip" ename "_delete") ; remove existing clip if exist

    (if (= ctr 1)
     (setq p3 (mapcar '- p1 p0) p4 (mapcar '- p2 p0))
    )

    (setq p5 (mapcar '+ p0 p3))
    (setq p6 (mapcar '+ p0 p4))
    
    (command "._pdfclip" ename "_New" "_Rectangular" p5 p6)
   ); progn
  ); foreach
 ); if

 ;(setvar "osmode" oldsnap)

 (command "._undo" "_end")
 (setvar "cmdecho" 1)

 (princ)
)

 

0 Likes
Message 13 of 16

Moshe-A
Mentor
Mentor
Accepted solution

@_anonandon ,

 

check this fix

 

 

Message 14 of 16

_anonandon
Advocate
Advocate

thanks for that. I've tested a bit and working well.

 

What is _None doing to the command??

0 Likes
Message 15 of 16

Moshe-A
Mentor
Mentor

@_anonandon ,

 


@_anonandon wrote:

thanks for that. I've tested a bit and working well.

 

What is _None doing to the command??


Tell you a secret (no one here is listening 😀)

 

AutoCAD has two sets of Object Snaps:

1. Temporary override osnap, valid for the next point.

2. Steady override osnap, valid until you turn it off.

 

When set 2 is on, say with endp,midp,near and you start a line to snap to an intersection what do you do? 

you pick the intersection osnap - right?!

 

By doing that, you override the endp,midp,near - right?!

"None" is one of set 1 object snaps that says:  i want the next point to be with no object snap at all - isn't that beautiful? 😀

Autodesk programmers thought of everything...

 

enjoy

Moshe

 

0 Likes
Message 16 of 16

_anonandon
Advocate
Advocate

yes the Autodesk programmers are beautiful but that doesn't explain this lisp when i use it!!! (it's working fine, saved me clipping about 1000 pdfs this week 🙂

 

adding "none" doesn't affect snapping to a line/frame within a pdf and the clips are always where snapped

no "none" doesn't affect snapping to a line/frame within a pdf but the clips are sometimes in random places!!

0 Likes