Jump to content

Attach Image to specific layout


Jonathan Handojo

Recommended Posts

Hi hackers,

 

How can  I use (vla-AddRaster) but not on ModelSpace, rather on a specific layout or tab? Or is there no other way to do it other than:

 

(setvar 'CTAB <name_of_layout>)
(command "-insert" "attach" <file_name> <point> <scale> <rotation>)

I kinda despise using command as it's the slowest thing to do especially looping through thousands.

Link to comment
Share on other sites

Use imageattach that works.

or

vla-AddRaster thespace you need to set the space to paperspace.

 

(setq mspace (vla-get-paperspace 
                 (vla-get-activedocument 
                      (vlax-get-acad-object))))

 

Edited by BIGAL
Link to comment
Share on other sites

48 minutes ago, BIGAL said:

Use imageattach that works.

or

vla-AddRaster thespace you need to set the space to paperspace.

 


(setq mspace (vla-get-paperspace 
                 (vla-get-activedocument 
                      (vlax-get-acad-object))))

 

 

I actually tried that too, but it went on the wrong layout even after doing (setvar "CLAYOUT" <layout_name>)

Link to comment
Share on other sites

1 hour ago, BIGAL said:

Use imageattach that works.

or

vla-AddRaster thespace you need to set the space to paperspace.

 


(setq mspace (vla-get-paperspace 
                 (vla-get-activedocument 
                      (vlax-get-acad-object))))

 

Oh, nevermind, I figured it out... you have to set the paperspace AFTER doing (setvar "CLAYOUT" <layout_name>)... Previously I was doing it BEFORE, hence the reason it failed.

Link to comment
Share on other sites

If you use addraster and have the layout name to reference, the tab does not need to be made current .. here's a simple example.

(vl-load-com)
(setq sp (vla-get-block
	   (vla-item (vla-get-layouts (vla-get-activedocument (vlax-get-acad-object)))
		     ;; Name of your layout to add raster
		     (car (layoutlist))
	   )
	 )
)
;; Add a line
(vlax-invoke sp 'addline '(0. 0. 0.) '(1. 1. 1.))
;; Add raster
(if (setq f (findfile "path to your image"))
  (vlax-invoke sp 'addraster f '(0. 0. 0.) 1 0)
)

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...