Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Contributor
weedseed85
Posts: 33
Registered: ‎02-05-2013
Message 1 of 11 (767 Views)
Accepted Solution

Get layout size, place block at calculated point

767 Views, 10 Replies
02-13-2013 05:45 AM

Dear autocad user, lisp users,

 

Will you please help me.

I would like to create a lisp that places a block at a pre-calculated point.

 

I've created a lisp that fetches me a block to place into my drawing. The only thing is

I have to point out the place i want it to go. I want it to got into the corner by it self.

 

I would like to create a lisp that calculates, by the retrieved variable of the layout / paperspace, minus 10

from the bottom right corner. minus 10 from the bottom up and from the right edge to the left.

 

It seem so easy when I write it... But Still No Luck

Please help me.

 

In advance, Thank you.


weedseed85 wrote:

....

It works perfectly.

.... I would really like to _PASTCLIP the block at the point your lisp is giving

....


That works pretty much the same way as Insert, just without the Block name, or the scales or rotation [unless you call for them as options].  This should do it [untested]:

 

(defun C:PasteStuff () ; edit blue parts as desired

  (command

    "_.pasteclip"

    (list ; insertion point

      (- (car (getvar 'limmax)) 10); X = 10 in from right

      10 ; Y = 10 up from bottom

      0 ; Z component [may not be needed]

    ); end list

  ); end command

); end defun

*Expert Elite*
hmsilva
Posts: 3,327
Registered: ‎12-17-2004
Message 2 of 11 (743 Views)

Re: Get layout size, place block at calculated point

02-14-2013 02:36 AM in reply to: weedseed85

weedseed85 wrote:
...
I would like to create a lisp that places a block at a pre-calculated point.
...
I would like to create a lisp that calculates, by the retrieved variable of the layout / paperspace, minus 10
...
It seem so easy when I write it... But Still No Luck
...

I understand that you want to create a lisp to insert a block in a specific point at the layout.
I do not understand what is the paper limit you want to grab, if you want to grab the plotting area or the entire sheet.
I don't understand, also, the location of the point relative to the previous area, try to define better the displacement
from the boundary area, if necessary attach an explanatory dwg.
And as you have written "It seem so easy when I write it"  post the code you have so far.
So maybe it is easier someone can help.


Henrique

Active Contributor
weedseed85
Posts: 33
Registered: ‎02-05-2013
Message 3 of 11 (731 Views)

Re: Get layout size, place block at calculated point

02-14-2013 05:03 AM in reply to: hmsilva

Dear Henrique,

 

Thank your for your reply.

 

The limit, I think is, the edge of the paper. 

I've added a image that will explain my plot configurations better.

It also show the offset of the paper, for the block placement.

 

I hope that explains all your questions about the displacement.

 

Futher more, I don't really know all that much about LISP. I know

what i want. I just don't know how to write / create it.

Thus the line "It seem so easy when I write it" 

 

For this particulair question. I've not written anny lisp. I made use of autocad's actionrecorder.

 

I hope a answerd all of your questions.

If not, please ask.

 

Thank you verry much for your help.

 

Greets,

Michel 

*Expert Elite*
Kent1Cooper
Posts: 5,868
Registered: ‎09-13-2004
Message 4 of 11 (723 Views)

Re: Get layout size, place block at calculated point

02-14-2013 06:01 AM in reply to: weedseed85

weedseed85 wrote:

....

I would like to create a lisp that places a block at a pre-calculated point.

....

I have to point out the place i want it to go. I want it to got into the corner by it self.

 

I would like to create a lisp that calculates, by the retrieved variable of the layout / paperspace, minus 10

from the bottom right corner. minus 10 from the bottom up and from the right edge to the left.

....


I assume the Block is to be at X & Y scale factors of 1 and a rotation of 0, and that the corner you're measuring from is the lower right of the paper-space limits, rather than of something like a border line in a title-block Xref.  The LIMMAX System Variable defines the upper right corner of the limits, and you can extract the separate components from that, as from any point list.  Try something like this [untested]:

 

(defun C:PlaceBlock () ; edit blue parts as desired

  (command

    "_.insert"

    "YourBlockName"

    (list ; insertion point

      (- (car (getvar 'limmax)) 10); X = 10 in from right

        ; (car (getvar 'limmax)) = X component of upper-right corner of limits

      10 ; Y = 10 up from bottom

      0 ; Z component [may not be needed]

    ); end list

    "" "" "" ; default scales & rotation

  ); end command

); end defun

Kent Cooper
*Expert Elite*
hmsilva
Posts: 3,327
Registered: ‎12-17-2004
Message 5 of 11 (712 Views)

Re: Get layout size, place block at calculated point

02-14-2013 06:59 AM in reply to: weedseed85

Michel,
after Kent's post, with quote, I realized the problem was mine, I misread your post, and I was reading (in my mind), an extra "10 from the top", therefore made no sense to me...I'm getting too old and I need new glasses :smileyvery-happy:
Thankfully, Kent Cooper understood that correctly and wrote a code for you, that will be certainly always much better than one made by me.

 

Henrique

 

Active Contributor
weedseed85
Posts: 33
Registered: ‎02-05-2013
Message 6 of 11 (695 Views)

Re: Get layout size, place block at calculated point

02-14-2013 11:11 PM in reply to: Kent1Cooper

Dear Kent Cooper,

 

Thank you verry mucht for that well explained lisp.

I will try and see what happens.

 

Thank you.

 

Greets Michel 

Active Contributor
weedseed85
Posts: 33
Registered: ‎02-05-2013
Message 7 of 11 (693 Views)

Re: Get layout size, place block at calculated point

02-14-2013 11:15 PM in reply to: hmsilva

Dear Henrique,

 

I occasionally miss read things as well. 

No matter.

 

Thank you for your reply.

 

Greets Michel

Active Contributor
weedseed85
Posts: 33
Registered: ‎02-05-2013
Message 8 of 11 (688 Views)

Re: Get layout size, place block at calculated point

02-14-2013 11:36 PM in reply to: Kent1Cooper

It works :smileyvery-happy: 

 

It works perfectly.

The only thing I would like to do with it is, to 

_PASTCLIP a copied block.

 

For example,

I input a block into the MODELSPACE and COPY it from it's INSERTION POINT.

After copying I go to the LAYOUT / PSPACE.

Here I would really like to _PASTCLIP the block at the point your lisp is giving

 

Do you think that would be possible?

 

I look forward to your reaction.

 

Greets,

Michel

*Expert Elite*
Kent1Cooper
Posts: 5,868
Registered: ‎09-13-2004
Message 9 of 11 (674 Views)

Re: Get layout size, place block at calculated point

02-15-2013 05:38 AM in reply to: weedseed85

weedseed85 wrote:

....

It works perfectly.

.... I would really like to _PASTCLIP the block at the point your lisp is giving

....


That works pretty much the same way as Insert, just without the Block name, or the scales or rotation [unless you call for them as options].  This should do it [untested]:

 

(defun C:PasteStuff () ; edit blue parts as desired

  (command

    "_.pasteclip"

    (list ; insertion point

      (- (car (getvar 'limmax)) 10); X = 10 in from right

      10 ; Y = 10 up from bottom

      0 ; Z component [may not be needed]

    ); end list

  ); end command

); end defun

Kent Cooper
Active Contributor
weedseed85
Posts: 33
Registered: ‎02-05-2013
Message 10 of 11 (662 Views)

Re: Get layout size, place block at calculated point

02-18-2013 12:29 AM in reply to: Kent1Cooper

It's perfect :smileyvery-happy:

 

It's excactly the way I wanted.

 

 

Thank you verry, verry much for your help.

 

Greets,

Michel

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.