Author Topic: Lisp to Create viewport  (Read 36290 times)

0 Members and 2 Guests are viewing this topic.

martinle

  • Newt
  • Posts: 22
Re: Lisp to Create viewport
« Reply #15 on: July 12, 2012, 12:05:10 AM »
Hello Mr. Kruuger!

I believe I have found the error.
When I go to "Select first point of view:" A window on the lower left to upper right aufziehe then it works. When I became a window from bottom right to top left aufziehe is the error message!
Could this be the problem?

Martin

martinle

  • Newt
  • Posts: 22
Re: Lisp to Create viewport
« Reply #16 on: July 12, 2012, 12:41:21 AM »
addendum:

Hello Mr. Kruuger

Furthermore, I noticed when ucs not "world" then it brings the wrong section of the layout.
Maybe this helps even more.

Martin

Lee Mac

  • Seagull
  • Posts: 12905
  • London, England
Re: Lisp to Create viewport
« Reply #17 on: July 12, 2012, 07:21:21 AM »
After a brief glance over the code, as a quick fix I would say change Line 83 / 84:

Code: [Select]
(/ (- (car p2) (car p1)) sc)
(/ (- (cadr p2) (cadr p1)) sc)

to:

Code: [Select]
(abs (/ (- (car p2) (car p1)) sc))
(abs (/ (- (cadr p2) (cadr p1)) sc))

martinle

  • Newt
  • Posts: 22
Re: Lisp to Create viewport
« Reply #18 on: July 12, 2012, 11:43:37 PM »
Hello Mr. Kruuger
Hello Mr. Lee!

After the change, according to Mr. Lee is now no error message.
It works in the "UCS" world very well.
But if I have turned my plan in model space in the user coordinate system and then create a new viewport does not fit the new viewport in the layout. The section shown is postponed.
As I said, everything fits in the world UCS. Not only in the user coordinate system. :-(

Greetings

Martin

Hugo

  • Bull Frog
  • Posts: 422
Re: Lisp to Create viewport
« Reply #19 on: July 13, 2012, 12:49:22 AM »
Hallo

I would like to have the insertion point of the bottom left to change what I need there.
Thank you

Ich würde gern den Einfügepunkt links unten haben was muss ich da ändern.
Danke

smemo

  • Mosquito
  • Posts: 19
Re: Lisp to Create viewport
« Reply #20 on: July 25, 2012, 08:59:50 AM »
This is the version I wrote a while ago and I also used to improve the functions of:
Bill Kramer: "HarryDialog1.lsp/dcl";
Tee Square Graphics: "SAVARS.LSP";
Gilles Chanteau: "ArchSort" and "SplitStr";
Marc'Antonio Alessi: "ALE_ReplaceFirst" and "ALE_List_RemoveNth";
Lee McDonnell: "ADjoin", "toTop", "Remove_nth", "write_config", "read_config" and "GetLays".
LOAD.LSP the file used to load the various lisp.
CFL to run
I hope I have made ​​a decent translation

antistar

  • Guest
Re: Lisp to Create viewport
« Reply #21 on: July 25, 2012, 06:23:31 PM »
This is the version I wrote a while ago and I also used to improve the functions of:
Bill Kramer: "HarryDialog1.lsp/dcl";
Tee Square Graphics: "SAVARS.LSP";
Gilles Chanteau: "ArchSort" and "SplitStr";
Marc'Antonio Alessi: "ALE_ReplaceFirst" and "ALE_List_RemoveNth";
Lee McDonnell: "ADjoin", "toTop", "Remove_nth", "write_config", "read_config" and "GetLays".
LOAD.LSP the file used to load the various lisp.
CFL to run
I hope I have made ​​a decent translation

Hi smemo,
Excellent research work.
It is very useful to me.

 However, I have two requests:
 
- Do not want to create the dimstyles cfstandard, cfMeccanico and cfArchitettonico;
- Disable the frame OPTION in DCL box.

 Thanks in advance    

smemo

  • Mosquito
  • Posts: 19
Re: Lisp to Create viewport
« Reply #22 on: July 26, 2012, 02:15:13 AM »
You need to comment in the file lisp lines:
Code: [Select]
953 (StiliDIM)
959 (ListaDimStili)
965 (set_tile "$CSD" "0")
966 (setq CreDimScala "0")
974 (mode_tile "$DST" 1)
983 (action_tile "$CSD" "(setq CreDimScala (get_tile \"$CSD\"))(if (= CreDimScala \"1\" )(congela)(scongela))")
990 (action_tile "$DST" "(setq DS_nlst (atoi $value))")
999 (setq DS_nlst (atoi (get_tile "$DST")))
1000 (setq StQuo (nth DS_nlst ListaDS))
1023 (if (/= CreDimScala "1")
1033 );if
1035 (if (= CreDimScala "1")
1036 (progn
1037     (command "_.-dimstyle" "_restore" StQuo)
1038 (CreaStyDim)
1039 (setvar "textsize" (/ 2.5 (distof FattZoom 2)))
1040 ;; Se è stato selezionato la creazione delle quote imposta anche l'altezza dei testi a 2.5 mm
1041     )
1042 )

and comment in the file DCL lines:
Code: [Select]
100 : toggle {
101 label = "Creates only Style DIM";
102 key = "$CSD";
103 value = "0";
104 }
105 : popup_list {
106 label = "from Style:";
107 key = "$DST";
108 width = 30 ;
109 allow_accept = false;
110 }

luisternou

  • Newt
  • Posts: 32
Re: Lisp to Create viewport
« Reply #23 on: June 19, 2014, 12:36:34 PM »
As result of the first post about how to create a viewport in modelspace, the code listed below only works in WCS. Most off the time I'm working in a UCS. If I use this lisp in UCS it doesn't work.
Please, can someone help!!

Thanks in advance!!


Code: [Select]
(defun c:NV (/ *error* _RestoreView p1 p2 doc ct vs vc tmp mp sc ll sl res vpdoc vpp vp ans)
  (defun *error* (Msg)
    (princ "Error: ")
    (princ Msg)
    (if ct (_RestoreView))
    (princ)
  )
  (defun _RestoreView ()
    (setvar "ctab" ct)
    (vla-ZoomCenter (vlax-Get-Acad-Object) (vlax-3d-Point (trans vc 1 0)) vs)
  )
  (vl-load-com)
  (if (/= (getvar "cvport") 1)
    (if
      (and
        (setq p1 (getpoint "\nSelect first point of view: "))
        (setq p2 (getcorner p1 "\nSelect second point of view: "))
      )
      (progn
        (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))
              ct (getvar "ctab")
              vs (getvar "viewsize")
              vc (getvar "viewctr")
              sc (cond
                   ( (getint
                       (strcat
                         "\nWhat is Viewport Scale 1: <"
                         (itoa (setq sc (cond (sc) (50))))
                         ">: "
                       )
                     )
                   )
                   ( sc )
                 )
        )
        (setq ll
          (vlax-for % (vla-get-layouts doc)
            (setq res
              (cons
                (list
                  (vla-get-name %)
                  %
                  (vla-get-TabOrder %)
                )
                res
              )
            )
          )
        )
        (setq ll
          (cdr
            (vl-sort ll
             '(lambda (a b)
                (< (last a) (last b))
              )
            )
          )
        )
        (if (setq sl (cd:DCL_StdListDialog (mapcar ' car ll) 0 "NewViewport" "Select layout:" 40 15 2 nil T T))
          (progn
            (setvar "ctab" (car (nth sl ll)))
            (vla-put-MSpace doc :vlax-false)
            (if (setq vpp (getpoint "\nSelect Point for Viewport: "))
              (progn
                (if
                  (<
                    (car (trans p2 1 0))
                    (car (trans p1 1 0))
                  )
                  (setq tmp p1 p1 p2 p2 tmp)
                )
                (setq mp
                  (list
                     (/ (+ (car p1) (car p2)) 2)
                     (/ (+ (cadr p1) (cadr p2)) 2)
                     0.0
                  )
                )
                (setq vpdoc (vla-get-PaperSpace doc)
                      vp (vla-AddPViewport
                           vpdoc
                           (vlax-3d-point vpp)
                           (abs (/ (- (car p2) (car p1)) sc))
                           (abs (/ (- (cadr p2) (cadr p1)) sc))
                         )
                )
                (vla-display vp :vlax-true)
                (vla-put-MSpace doc :vlax-true)
                (vla-put-ActivePViewport doc vp)
                (vla-ZoomCenter
                  (vlax-get-acad-object)
                  (vlax-3d-point mp)
                  1.0
                )
                (vla-put-CustomScale vp (/ 1. sc))
                (vla-put-MSpace doc :vlax-false)
                (vla-put-DisplayLocked vp :vlax-true)
                (initget "Yes No")
                (setq ans
                  (cond
                    ( (getkword "\nBack to model space [Yes/No] <No>: ") )
                    ( "No" )
                  )
                )
                (if (= ans "Yes") (_RestoreView))
              )
              (progn
                (princ "\n** Invalid Point ** ")
                (if ct (_RestoreView))
              )
            )
          )
          (princ "\n** Layout not selected ** ")
        )
      )
      (princ "\n** Invalid Point ** ")
    )
    (princ "\nStart Program in Model Space ")
  )
  (princ)
)
; =========================================================================================== ;
; Okno dialogowe z lista (list_box) / Dialog control with list (list_box)                     ;
;  Data      - lista do wyswietlenia / list to display                              ;
;  Pos       [INT]     - pozycja poczatkowa na liscie / select list position                  ;
;  Title     [STR/nil] - tytul okna / window title                                            ;
;  ListTitle [STR/nil] - tytul list_box / list_box title                                      ;
;  Width     [INT]     - szerokosc / width                                                    ;
;  Height    [INT]     - wysokosc / height                                                    ;
;  Btns      [0/1/2]   - [cancel/ok/ok_cancel] przyciski / buttons                            ;
;  MSelect   [T/nil]   - dopuszczenie multiple_select / allow multiple select                 ;
;  DPos      [T/nil]   - zapamietanie pozycji okna / save window position                     ;
;  DblClick  [T/nil]   - podwojny klik (wykluczone Cancel) / double click (not for Cancel)    ;
; ------------------------------------------------------------------------------------------- ;
; Zwraca / Return:                                                                            ;
;  nil  = nic nie wybrano (anulowano) / nothing was selected (canceled)                       ;
;  INT  = wybrano jedna pozycje / one position selected  | MSelect = nil                      ;
;  LIST = wybrano kilka pozycji / few positions selected | MSelect = T                        ;
; ------------------------------------------------------------------------------------------- ;
; (cd:DCL_StdListDialog '("A" "B" "C") 0 "Title" "ListTitle:" 40 15 2 nil T nil)              ;
; =========================================================================================== ;
(defun cd:DCL_StdListDialog (Data Pos Title ListTitle Width Height Btns MSelect DPos DblClk
                             / f tmp dc res)
  (if (not DPos) (setq *cd-TempDlgPosition* (list -1 -1)))
  (cond
    ( (not
        (and
          (setq f
            (open
              (setq tmp (vl-FileName-MkTemp nil nil ".dcl"))
              "w"
            )
          )
          (foreach %
            (list
              "StdListDialog:dialog{"
              (strcat "label=\""
                (if Title (strcat Title "\";") "\"\";")
              )
              ":list_box{key=\"list\";"
              (if ListTitle
                (strcat "label=\"" ListTitle "\";")""
              )
              "fixed_width=true;fixed_height=true;"
              (strcat "width="
                (if (not Width) "20" (itoa Width))";"
              )
              (strcat "height="
                (if (not Height) "20" (itoa Height))";"
              )
              (if (not DblClck)
                (strcat "multiple_select="
                  (if MSelect "true;" "false;")
                )
                "multiple_select=false;"
              )
              "}"
              (cond
                ( (zerop Btns) "cancel_button;")
                ( (= 1 Btns) "ok_only;")
                (T "ok_cancel;")
              )
              "}"
            )
            (write-line % f)
          )
          (not (close f))
          (< 0 (setq dc (load_dialog tmp)))
          (new_dialog "StdListDialog" dc ""
            (cond
              ( *cd-TempDlgPosition* )
              ( (quote (-1 -1)) )
            )
          )
        )
      )
    )
    ( T     
      (start_list "list")
      (mapcar (quote add_list) Data)
      (end_list)
      (if (not Pos)
        (setq Pos 0)
        (if (> Pos (length Data)) (setq Pos 0))
      )
      (setq res (set_tile "list" (itoa Pos)))
      (action_tile "list"
        (strcat
          "(setq res $value)(if DblClk (if(or(not MSelect)"
          "(not (zerop Btns)))"
          "(if (= $reason 4)(setq "
          "*cd-TempDlgPosition* (done_dialog 1)))))"
        )
      )
      (action_tile "accept" "(setq *cd-TempDlgPosition* (done_dialog 1))")
      (action_tile "cancel" "(setq res nil) (done_dialog 0)")
      (setq res
        (if (= 1 (start_dialog))
          (read (strcat "(" res ")"))
          nil
        )
      )         
    )
  )
  (if (< 0 dc) (unload_dialog dc))
  (if (setq tmp (findfile tmp)) (vl-File-Delete tmp))
  (if (not DPos) (setq *cd-TempDlgPosition* (list -1 -1)))
  (if res (if (= 1 (length res)) (car res) res))
)
(princ "\n Type NV to Invoke ")
(princ)
« Last Edit: June 22, 2014, 09:54:32 AM by CAB »

luisternou

  • Newt
  • Posts: 32
Re: Lisp to Create viewport
« Reply #24 on: June 21, 2014, 06:03:35 PM »
Anybody?  :roll:

luisternou

  • Newt
  • Posts: 32
Re: Lisp to Create viewport
« Reply #25 on: June 21, 2014, 06:05:02 PM »
......much appreciated!!!  :-)

luisternou

  • Newt
  • Posts: 32
Re: Lisp to Create viewport
« Reply #26 on: June 21, 2014, 06:20:52 PM »
....the solution is near! See topic:
http://www.theswamp.org/index.php?topic=47145.0;all
Big thanks to Roy_43!!

luisternou

  • Newt
  • Posts: 32
Re: Lisp to Create viewport
« Reply #27 on: April 23, 2015, 12:45:20 PM »
....is there someone to help? Thanks in advance!!!!  :-)

kruuger

  • Swamp Rat
  • Posts: 625
Re: Lisp to Create viewport
« Reply #28 on: April 24, 2015, 04:21:22 AM »
....is there someone to help? Thanks in advance!!!!  :)
check this tool. also in english.
http://forum.cad.pl/viewportmaster-mened-er-rzutni-t84275.html
kruuger

luisternou

  • Newt
  • Posts: 32
Re: Lisp to Create viewport
« Reply #29 on: May 01, 2015, 06:39:11 AM »
Thanks Kruuger for the tip! Sorry for the late respond! This could be more then I expected!  :-)