Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Viewport ObjId

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
wingfold2001
600 Views, 5 Replies

Viewport ObjId

Greetings. All I need is to know the ObjID of the viewport so I can include it in a script. I have many layouts with one viewport in each. If your product prints it out in text form, I'll sort it out from there.

 

I'm puting a field in each title block that references the viewport ObjID to indicate the scale. For instance:

%<\AcObjProp Object(%<\_ObjId -1075771920>%).StandardScale2 \f "%en0">%

 

Showing a viewport ObjID table for all layouts, would also work. You guys are terrific.

5 REPLIES 5
Message 2 of 6
hmsilva
in reply to: wingfold2001

if I understood correctly, something like this perhaps...

 

(defun c:test ( / HND ITM LAYT LST NUM SS VP)
  
    (vl-load-com)

  ;; by Gilles Chanteau
  (defun gc:GetObjectIdString (obj)
    (or	*util*
	(setq *util* (vla-get-Utility
		       (vla-get-ActiveDocument (vlax-get-acad-object))
		     )
	)
    )
    (if	(vlax-method-applicable-p *util* 'GetObjectIdString)
      (vla-GetObjectIdString *util* obj :vlax-false)
      (itoa (vla-get-ObjectId obj))
    )
  );; gc:GetObjectIdString
  
    (if (setq ss (ssget "_X" '((0 . "VIEWPORT") (410 . "~Model"))))
        (progn
            (setq num (length (layoutlist))
                  itm -1
            )
            (while (and (< (length lst) num) (setq hnd (ssname ss (setq itm (1+ itm)))))
	      (setq vp (gc:GetObjectIdString (vlax-ename->vla-object hnd)))
                (if (not (assoc (setq layt (cdr (assoc 410 (entget hnd)))) lst))
                    (setq lst (cons (cons layt vp) lst))
                )
            )
           (textscr)
	  (setq lst (reverse lst))
	  (foreach n lst
	    (princ "\n")
	    (princ n)
	    )
        )
    )
  (princ)
)

 

@ Lee Mac

sorry Lee,  but I used part of a code you posted...

I'm getting too lazy Smiley Wink

 

HTH

Henrique

 

 

EESignature

Message 3 of 6
Lee_Mac
in reply to: hmsilva


@hmsilva wrote:
@ Lee Mac

sorry Lee,  but I used part of a code you posted...

I'm getting too lazy Smiley Wink


No problem! - thank you for your acknowledgement Smiley Happy

Message 4 of 6
wingfold2001
in reply to: wingfold2001

Thanks for posting. I'll test it after the 1st of the year. V/r

Message 5 of 6
hmsilva
in reply to: wingfold2001


@wingfold2001 wrote:

Thanks for posting. I'll test it after the 1st of the year. V/r


You're welcome, wingfold2001
Let's wait...


Henrique

EESignature

Message 6 of 6
wingfold2001
in reply to: wingfold2001

Thank you, it works perfectly.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost