Jump to content

Changeing layout's viewport's focal point in model space with VBA


Scion

Recommended Posts

I have few hundreds of autocad drawings which are maps. My customer changed his coordinate system for maps and wants me to change all the old maps to new coordinate system. He didn't accept that I define new UCS for those maps but insists that I must move and rotate all the objects in the map to new position in World UCS. Bigger problem than moving and rotate all objects was elevation numbers which were normal acad text objects containing earth surface elevation as number.

 

I made a VBA program and solved those problems with it.

 

But a new problem came out. Every drawing has 10 to 40 layouts and now every viewport in those layouts points at wrong place in model space.

 

I have been trying to work out how to fix it with VBA but without success. So is here anybody who can help me with this problem?

Link to comment
Share on other sites

This may be a way the variable Viewctr is the center pt of a viewport so read all viewports first and then translate to new co-ords and reset the zoom center for each layout then do your move plan. Note Viewctr changes as you go to each viewport.

 

Use zoom c newcpt must be in model space. lisp (command "zoom" "c" newpt "") Note provided you have not zoomed in the viewport the scale should be correct

 

Almost forget need to check that viewport is not locked.

 

Not tested a lisp version

(setq doc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lay (vla-get-Layouts doc)
(setq plotabs (cons (vla-get-name lay) plotabs))
)

(foreach tabname plotabs 
(setvar "ctab" tabname)
(command "mspace")
(setq cpt (getvar "viewctr"))
(setq cpt (list (+ x (car cpt))(+ y (cadr cpt))(+ z (caddr cpt))))
(command "z" "c" cpt "")
)

Edited by BIGAL
Link to comment
Share on other sites

I have few hundreds of autocad drawings which are maps. My customer changed his coordinate system for maps and wants me to change all the old maps to new coordinate system. He didn't accept that I define new UCS for those maps but insists that I must move and rotate all the objects in the map to new position in World UCS. Bigger problem than moving and rotate all objects was elevation numbers which were normal acad text objects containing earth surface elevation as number.

 

I made a VBA program and solved those problems with it.

 

But a new problem came out. Every drawing has 10 to 40 layouts and now every viewport in those layouts points at wrong place in model space.

 

I have been trying to work out how to fix it with VBA but without success. So is here anybody who can help me with this problem?

 

Next time just wblock the entire drawing after you define the new UCS. In the new drawing, the world coordinate system (WCS) is set parallel to the user coordinate system (UCS).

http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-F26FC1CE-45C9-4C85-9DB9-19B6A597D87B

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