Jump to content

lisp tool to convert closed polyline to a viewport - help me make it better.


fuqua

Recommended Posts

you really gonna make me form a decent question ? :D :shock:

 

I am really do not know what you want to do ? can you explain it or it is hard ?:shock:

 

I am going home right now but I will resume when I arrive . So take your time to make it clear .:lol:

Link to comment
Share on other sites

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

  • fuqua

    15

  • Tharwat

    9

  • alanjt

    2

  • mdbdesign

    1

I am really do not know what you want to do ? can you explain it or it is hard ?:shock:

 

I am going home right now but I will resume when I arrive . So take your time to make it clear .:lol:

 

lol ok :)

 

when using the chspace command in the lisp tool it gives some trouble, we think it cause it does not know which viewport to choose from since we got 2 viewports (1 small 1 big) how can we make clear in the tool which viewport it should use to convert the closed polyline to a new viewport ?

Link to comment
Share on other sites

Are you trying to move the closed polyline to model space through the command chspace ? or as we did before convert it to be Viewport ?

 

Post your codes to let us see .

Link to comment
Share on other sites

Just saw this thread and thought I'd comment on tharwat's code. You could condense things down a bit. I know you are coding for single selection, but when multiple is available, why not...

 

(defun c:LWP2VP (/ ss i)
 (cond ((> (getvar 'CVPORT) 1) (princ "\n ** Command not allowed in Model Tab ** "))
       ((setq ss (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
        (repeat (setq i (sslength ss)) (command "_.mview" "_object" (ssname ss (setq i (1- i)))))
       )
 )
 (princ)
)

 

Also, no VLISP required.

Link to comment
Share on other sites

Are you trying to move the closed polyline to model space through the command chspace ? or as we did before convert it to be Viewport ?

 

Post your codes to let us see .

 

;;; vpcl-create-viewport-from-a-polyline
;;; version 0.2
;;; 
(defun c:vpcl (/ clgr vpla ; polyline viewport-orriginal
             )
 (princ "\n**select-polyline\n")
 (command "_mspace") ;to be sure
 (setq clgr (car (entsel "Select polyline to convert.") ) )
 (princ "\n**chspace\n")
 (command "_chspace" clgr "" )
 (princ "\n**pspace\n")
 (command "_pspace")
 (princ "\n**vports\n")
 (command "-vports" "o" clgr )
 (princ "\n**select-vp\n")
 (setq vpla (car (entsel "Select main viewport to sync with.") ) )
 (princ "\n**vpsync"\n)
 (command "_vpsync" );vpla clgr "\n" )
 (princ "\n**ready\n")
)

 

this is how we used to do it; we are pushing a closed polyline to modelspace and then convert it to be a viewport, then that viewport has to sync with the already existing main viewport. so it has the right scale and location.

 

trouble we are having is it does not know which (existing) viewport to choose from since we got 2 and a 3th has to be created and synced up with the big viewport.

Link to comment
Share on other sites

Just saw this thread and thought I'd comment on tharwat's code. You could condense things down a bit. I know you are coding for single selection, but when multiple is available, why not...

 

(defun c:LWP2VP (/ ss i)
 (cond ((> (getvar 'CVPORT) 1) (princ "\n ** Command not allowed in Model Tab ** "))
       ((setq ss (ssget "_:L" '((0 . "LWPOLYLINE") (-4 . "&=") (70 . 1))))
        (repeat (setq i (sslength ss)) (command "_.mview" "_object" (ssname ss (setq i (1- i)))))
       )
 )
 (princ)
)

 

Also, no VLISP required.

 

how can we implement this is in our tool (vlisp) and what do you exactly mean by "no vlisp required" ?

Link to comment
Share on other sites

this is how we used to do it; we are pushing a closed polyline to modelspace and then convert it to be a viewport, then that viewport has to sync with the already existing main viewport. so it has the right scale and location.

 

trouble we are having is it does not know which (existing) viewport to choose from since we got 2 and a 3th has to be created and synced up with the big viewport.

 

What we have been discussing til now ?

 

You still talking about you precious routine and we are talking about converting a LWpolyline to Viewport .

 

I would stop at this point .

 

Bye .

Link to comment
Share on other sites

What we have been discussing til now ?

 

You still talking about you precious routine and we are talking about converting a LWpolyline to Viewport .

 

I would stop at this point .

 

Bye .

 

sorry wrong code, this is what we have so far with your help and the tip we got from lee mac, gonna try alanjt bit of code to (i understand it solved the 2 viewport issue, right ?)

 

;;; vpcl-viewport-van-clustergrens
;;; versie 0.2
;;; 
(defun c:vpcl (/ clgr ss ent;
             )
 (command "_mspace") ;voor de zekerheid
 (setq clgr (entsel "Select polyline to convert: ") )
 (command "_chspace" (car clgr) "" )
 (command "_pspace")
 ;; Tharwat 26. 07. 2011
 (princ"\n")
 (vl-load-com)
 (princ "Select polyline to convert to viewport ")
 (cond ((not
          (eq (vla-get-Activespace
                (vla-get-activedocument (vlax-get-acad-object))
              )
              acPaperSpace
          )
        )
        (princ "\n ** Command not allowed in Model Tab ** ")
       )
       ((not (and (setq ss (ssget "_+.:L:S" '((0 . "LWPOLYLINE"))))
                  (vlax-curve-isclosed (setq ent (ssname ss 0)))
             )
        )
       )
       ((command "_.mview" "_object" ent))
 )
;  (princ "vports..\n")
;  (command "-vports" "O" "L" ) ;assume last created object is our viewport
 (princ "\nSelect master viewport: ")
 (c:vpsync)
 ;followed by vp-plotstyle overrides voor de `master'viewport
)

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...