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

Need a routine to Changspace all VP's

10 REPLIES 10
Reply
Message 1 of 11
gccdaemon
313 Views, 10 Replies

Need a routine to Changspace all VP's

Got a slew of out of state details that need conversion and they have several VP's per layout (Title Block is in layout and all detail portions are in model). I need a routine that will CHSPACE the objects in the view area of each viewport. I cannot have the routine select items outside of the viewport view area. Any help would be a great start.

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
10 REPLIES 10
Message 2 of 11
doni49
in reply to: gccdaemon

I don't have time right now to work on it but I'll offer some advice as to how I think you could do it.

 

Each view port has coordinates associated with it that tells acad what portions of model space is shown.  You should be able to loop through each VP and have it chspace everything from modelspace within the vp's coordinates to the layout.  The one thing to watch for the possibility that there is more than one VP that shows the same feature(s).

 

Maybe COPY the elements and then chspace them to the layout.  That way when you move to the next vp, those elements will still be there.  Once it's gone through all the VP's you can delete everything from model space.

 

Also keep in mind that if something extends beyond a VP, it will ALL be shown in the layout -- including what was previously beyond the VP.  You might need to trim some elements in such cases.

 

All-in-all it sounds like an interesting programming task.  I wish I had time to tinker with it.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 3 of 11
doni49
in reply to: doni49

Also:  be sure to watch out for any layers that have been frozen within specific vp's (VPFREEZE).  As elements on those layers will get copied in the layout as a result of this and you'll need to do something about that.



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 4 of 11
gccdaemon
in reply to: doni49

The VP freeze can be a later addition because it's not a high priority (I don't use VPfreeze because of the way I set my sheets up). You're definately onto something with "Copying" items before moving them to the layout. Perhaps as it rolls through each viewport adding object ID's in to a list to delete at the end of the routine.

 

Here is a list of how I thought it would run:

 

1. Layout / model check - to make sure in a layout

2. Get list of current layout VP's

3. Step through VP's

   a. Get VP point list

   b. Activate VP

   c. get ss1 using vp point list as selection window

   d. add ss to master list for later deletion

   e. copy ss list

   f. get ss2 using vp point list as selection window and remove ss1 objects

   g. CHSPACE ss2

4. Change to model & Delete master list from drawing

5. Reactivate initial layout

6. End Program

 

How would I be able to get the list of points for the viewport?

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 5 of 11
doni49
in reply to: gccdaemon


@gccdaemon wrote:

How would I be able to get the list of points for the viewport?




I haven't tested this myself.  But the OP in this thread basically asked the same question and marked this particular post as the solution.

 

So I think it's at least a good place to start.

 

http://forums.autodesk.com/t5/Visual-LISP-AutoLISP-and-General/viewport-coordinates/m-p/3194528#M299...



Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 6 of 11
hmsilva
in reply to: gccdaemon


gccdaemon wrote:

How would I be able to get the list of points for the viewport?


Hi Andrew.

 

VIEWPORTS...

 

If rectangular ones, with the GetBoundingBox method you can access to the lower left corner and upper right corner VIEWPORT coordinates.

 

This thread may be a starting point

 

If not, you'll need to entget the original entity (circle, *polyline, region, ellipse or spline) to extract the entity coordinates...

 

(setq ss (ssget '((0 . "VIEWPORT"))))

(setq hnd (ssname ss 0)

      vpent (entget hnd))

(if (setq ohnd (cdr (assoc 340 vpent)))

(setq oent (entget ohnd));; the original entity

)

 

In addition, try to do a search for viewport to model, or viewport outline...

 

HTH

Henrique

EESignature

Message 7 of 11
gccdaemon
in reply to: hmsilva

There are a few aspects I can't seem to grasp. If I'm able to get the point list of the viewport, how would I activate the viewport, and how would I translate the points to model space?

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 8 of 11
doni49
in reply to: gccdaemon

I think you're going to have figure out what elements you need and then use entmake to recreate them in the layout. I doubt if you'll be able to directly use chspace.


Don Ireland
Engineering Design Technician




If a reply solves your issue, please remember to click on "Accept as Solution". This will help other users looking to solve a similar issue. Thank you.


Please do not send a PM asking for assistance. That's what the forums are for. This allows everyone to benefit from the question asked and the answers given.

Message 9 of 11
hmsilva
in reply to: gccdaemon


@gccdaemon wrote:

There are a few aspects I can't seem to grasp. If I'm able to get the point list of the viewport, how would I activate the viewport, ...


(command ".mspace")

(setvar "cvport" (cdr (assoc 69 ent)))


@gccdaemon wrote:
 and how would I translate the points to model space?

(trans pt 3 2)

or

(trans (trans pt 3 2) 2 0)

Untested...

 

HTH

Henrique

 

EESignature

Message 10 of 11
gccdaemon
in reply to: gccdaemon

Still havn't been able to come up with a routine to do this. I'm really too buisy to work on it. Can anyone help me out by comming up with some beginning code? I have the old express tools change space command in lsp if anyone thinks it would help?

Andrew Ingram
Civil 3D x64 2019
Win 10 x64 Pro
Intel Xeon E5-1620
32 GB Ram
Message 11 of 11
hmsilva
in reply to: gccdaemon


@gccdaemon wrote:

Still havn't been able to come up with a routine to do this. I'm really too buisy to work on it. Can anyone help me out by comming up with some beginning code? I have the old express tools change space command in lsp if anyone thinks it would help?


Andrew,

just a "start point"...

 

As a "demo", will work in WCS, with an rectangular viewport and just for the first viewport found.

Reread messages #6 and #9 for the non-rectangular viewports and points transformation...

 

(defun c:demo (/ ent ll msllpt msurpt psllpt psurpt ss ssn ur VlaObj vp)
  (cond
    ((/= (getvar 'CVPORT) 1)
     (princ "\nNot allowed in ModelSpace!!! ")
    )
    ((setq vp (ssget "x"
		     (list '(0 . "viewport")
			   (cons 410 (getvar 'CTAB))
			   '(-4 . "/=")
			   '(69 . 1)
		     )
	      )
     )
     (setq ssn	  (ssname vp 0)
	   ent	  (entget ssn)
	   VlaObj (vlax-ename->vla-object ssn)
     )
     (vla-put-target VlaObj (vlax-3d-point '(0 0 0)))
     (vlax-invoke-method VlaObj 'GetBoundingBox 'll 'ur)
     (setq psllpt (vlax-safearray->list ll)
	   psurpt (vlax-safearray->list ur)
	   msllpt (trans psllpt 3 2)
	   msurpt (trans psurpt 3 2)
     )
     (command ".mspace")
     (setvar "cvport" (cdr (assoc 69 ent)))
     (if (setq ss (ssget "_C" msllpt msurpt))
       (if (= (sslength vp) 1)
	 (command "_.chspace" ss "")
	 (command "_.chspace" ss "" "")
	 )
       (progn
	 (command ".pspace")
	 (princ "\nNo objects were found to change space!!! ")
       )
     )
    )
  )
  (princ)
)

 

hope that helps

henrique

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost