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

create multiple viewport from multiple rectangle in model space

10 REPLIES 10
Reply
Message 1 of 11
marlance
3692 Views, 10 Replies

create multiple viewport from multiple rectangle in model space

Is there a lisp that would create multiple viewport by selecting multiple rectangle in model space with specified scale?

 see attachment in order

 

 

Tags (1)
10 REPLIES 10
Message 2 of 11
Zamfiroiu123
in reply to: marlance

hello, did u find what you were searching ?

Message 3 of 11
marlance
in reply to: Zamfiroiu123

hi there,

Unfortunately I haven't found yet the answer.

Still hoping that someone would step in to solve my problem.

Message 4 of 11
hmsilva
in reply to: marlance

Hi rulep21,

attach a sample dwg, with the before and after, and It should be easier to get some help.

 

Henrique

EESignature

Message 5 of 11
marlance
in reply to: hmsilva

Hi Henrique,

 

see attached below

 

 

thank you

Message 6 of 11
hmsilva
in reply to: marlance

Hi rulep21,

I have a deadline to meet, but tonight I'll see what I can do.

 

Henrique

EESignature

Message 7 of 11
hmsilva
in reply to: marlance

Hi Rulep21,
I'm with a very large workload, so, the following quickly written 'demo' is just a starting point for your code...

 

(defun c:demo (/ ctb i layout llpt ll llpt ss ur urpt)
   (if (= 1 (getvar "tilemode"))
      (if (= (length (layoutlist)) 1)
         (if (= (car (layoutlist)) "Layout1")
            (if (setq ss (ssget '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
               (progn
                  (setq ctb (getvar 'CTAB))
                  (setvar 'CTAB "Layout1")
                  (if (= 1 (getvar "cvport"))
                     (command "_.MSPACE")
                  )
                  (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq i (1- (sslength ss))))) 'll 'ur)
                  (setq llpt (vlax-safearray->list ll)
                        urpt (vlax-safearray->list ur)
                        layt 1
                  )
                  (command "_.zoom" llpt urpt)
                  (command "_.PSPACE")
                  (repeat i
                     (command "_.-layout"
                              "_C"
                              (getvar 'CTAB)
                              (setq layout (strcat "Layout" (itoa (setq layt (1+ layt)))))
                     )
                     (setvar 'CTAB layout)
                     (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'll 'ur)
                     (setq llpt (vlax-safearray->list ll)
                           urpt (vlax-safearray->list ur)
                     )
                     (command "_.MSPACE")
                     (command "_.zoom" llpt urpt)
                     (command "_.PSPACE")
                  )
                  (setvar 'CTAB ctb)
               )
               (princ "\n** You didn't select closed LwPolylines **")
            )
            (princ "\n** Command only allowed with one Layout Tab named \"Layout1\" **")
         )
         (princ "\n** Command only allowed with one Layout Tab **")
      )
      (princ "\n** Command not allowed in Layout Tab **")
   )
   (princ)
)

 

Hope this helps,
Henrique

EESignature

Message 8 of 11
marlance
in reply to: hmsilva

Hi Henrique,

 

Thanks for this one.

 

It works when the rectangle are on the same rotation.

What if they have different rotation?

I'm planning also to replace the rectangles with blocks (attributes) so that the layout name will match with the blocks.

 

 

 

 

see attachment below

 

Message 9 of 11
hmsilva
in reply to: marlance


@rulep21 wrote:

Hi Henrique,

 

Thanks for this one.

 

It works when the rectangle are on the same rotation.

What if they have different rotation?

I'm planning also to replace the rectangles with blocks (attributes) so that the layout name will match with the blocks.

 


You're welcome, rulep21

 

'It works when the rectangle are on the same rotation.'
Yes, your sample dwg only had rectangles with the same rotation... (And it was easier to write) 🙂

 

'What if they have different rotation?

I'm planning also to replace the rectangles with blocks (attributes) so that the layout name will match with the blocks.'

 

When we start to write a code, we have to know the final goal, in order to structure the code that way...

So, when we post a sample dwg, and if we want to be helped with the code we intend to write, it is advisable, to post a 'real' sample dwg.

 

As said in my previous post,

'I'm with a very large workload, so, the following quickly written 'demo' is just a starting point for your code...'

and without having seen these last drawings:

 

To use blocks with attributes with different rotation angles, probably you may continue to use the 'boundingbox', but you'll have to do a search for 'UCS boundingbox' function (I recall one from Gilles), to get the UCS BBox llpt and urpt for each block.

 

Pseudo code:

  • select the blocks
  • process each block
  • set a UCS to each block
  • get the UCS BBox llpt and urpt,
  • get the layout name from the attribute
  • store the previous data in a list
  • sort the list
  • create a new layout for each list element...

 

Hope this helps,
Henrique

Henrique

EESignature

Message 10 of 11
jeremie.belmonte
in reply to: marlance

Hi, have you benn able to implement the block + attribute function ?

I'm really impressed and intersted to use your lisp.

 

Thanks.

Message 11 of 11
pharuehus
in reply to: hmsilva

Multiple Rectangle Row and Column, This work for Down to Up, Please Modified code for left to right. Thank

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

Post to forums  

Autodesk Design & Make Report

”Boost