Zoom to center at the point pick up in another drawing

Zoom to center at the point pick up in another drawing

Bin2009
Advocate Advocate
1,996 Views
10 Replies
Message 1 of 11

Zoom to center at the point pick up in another drawing

Bin2009
Advocate
Advocate

Hello,

I am working on find a lisp. which able to pick a point at first drawing, then go to second drawing,  Zoom Center to the point pick up in the first drawing, I can set height at 100.

Is anyone can help, Thank very much in advance!

Bin

0 Likes
Accepted solutions (1)
1,997 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant
Accepted solution

AutoLisp routines cannot start in one drawing and continue in another.  You would need one in the first drawing to save the point, such as using the blackboard space, and another one in the second drawing to use that point for the Center option in Zoom.

 

This combination seems to work [minimally tested]:

 

(vl-load-com); if needed

(defun C:ZCset ()
  (vl-bb-set 'ZC (getpoint "\nPoint to use as Zoom Center in other drawing: "))
  (princ)
)

(defun C:ZCuse ()
  (command "_.zoom" "_c" (vl-bb-ref 'ZC) 100)
  (princ)
)

 

Kent Cooper, AIA
0 Likes
Message 3 of 11

Bin2009
Advocate
Advocate

Hello Kent,

Thank very much for your input, sorry for take so long get back to you.

I didn’t get how to use blackboard space save the point from first drawing, and how to use the lisp you give to me.

After I put command: ZCset, I has been asked “Point to use as Zoom Center in other drawing:”, I try to put the coordinate of the point, but looks not work.

I try to get the lisp have function similar as below one called “GE”, we use it in civil 3D, can get a point coordinate, save in memory, “GE” is covert the point coordinate to Latitude and Longitude, then quickly find that point in google earth.

I don’t need convert to Lat and Long, but I hope can save the point X, Y value in memory, then paste to next drawing when I use Zoom>>Center, for me can quickly locate the point location. The reason I need this function is that I always need looking for features in a reference drawing which cover very big area. So I hope can get someway can quickly zoom to the spot I am looking for.

GE – CIVIL3D command   - prompts you for a point, then based on your current coordinate system used it is creating in memory the coordinates of that point in lat and long. Then you have to open Google earth and to right click into the search box , choose paste and the coordinates from memory are been pasted into google earth. By clicking the search button into google earth you will be taken to the position of the point.

This command works with any coordinate system you may have chosen for your current drawing.

 

Bin2009_0-1611457328350.png

 

  

Bin2009_1-1611457328360.png

 

Thanks again,

Bin

0 Likes
Message 4 of 11

hak_vz
Advisor
Advisor

Try this

 

(defun c:cpypt ( / a b c) 
;https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/copy-string-to-clipboard/m-p/5607258/highlight/true#M331744

(setq a (getpoint "\nPick a point") b (rtos (car a) 2 5) c (rtos (cadr a) 2 5) a (strcat b "," c))
(vlax-invoke(vlax-get (vlax-get (vlax-create-object "htmlfile") 'ParentWindow) 'ClipBoardData)'setData "TEXT" a)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 11

Kent1Cooper
Consultant
Consultant

@Bin2009 wrote:

....

After I put command: ZCset, I has been asked “Point to use as Zoom Center in other drawing:”, I try to put the coordinate of the point....


How are you putting the coordinates?  You can simply pick a point with the cursor.  But it saves it in XYZ terms, not degrees of latitude and longitude.  And the ZCuse command uses it in XYZ terms, and it would require you to use that command, not the Google Earth way.  If that is not workable, but degrees of latitude and longitude are needed, it should have been mentioned in the first post.

Kent Cooper, AIA
0 Likes
Message 7 of 11

Sea-Haven
Mentor
Mentor

Civ3d can return Lat Long for points that is the end of my suggestion.

 

You can jump between dwgs using VL that looks at the dwg document list of all open dwgs but it can be a bit flaky.

Just some code to start with not solution.

 

(setq acDocs (vla-get-documents (vlax-get-acad-object)))
(vla-open acDocs blkname) ; opens new dwg
(vla-activate (vla-item acdocs 1))
;(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 1))

 

 

0 Likes
Message 8 of 11

Bin2009
Advocate
Advocate

Thanks Hak,

You provided the code is exactly I need, it copy the point x,y value to memory then I can use for next drawing zoom to center, Thank so much!

Bin

Message 9 of 11

Bin2009
Advocate
Advocate

Hi Kent,

I figure out how to use your code, your way is very simple and quick. It works great!

how silly was I misunderstand, 

Thank very much!

Bin

 

0 Likes
Message 10 of 11

Bin2009
Advocate
Advocate

Hello @diagodose2009 

Thank so much for your input, I am looking at your code now, since my limited knowledge on lisp, it might take me some time to get your idea, I will ask you if have any question,

Thanks again,

Bin

0 Likes
Message 11 of 11

Sea-Haven
Mentor
Mentor

This seems to work but will not do lat,long etc. I opened 2 dwgs for testing, ran the lisp in dwg2.

 

The item number starts at 0 not 1. So 2 dwgs item 0 & item 1. Could do a check dwg name if more than 2 dwgs open.

 

 

(defun c:test ( / acdocs)
(vl-bb-set 'ZC (getpoint "\nPoint to use as Zoom Center in other drawing: "))
(setq acDocs (vla-get-documents (vlax-get-acad-object)))
; (vla-open acDocs blkname) ; opens new dwg
; (vla-activate (vla-item acdocs 1))
(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 0))
(command "_.zoom" "_c" (vl-bb-ref 'ZC) 50)
(vla-put-activedocument (vlax-get-acad-object) (vla-item acdocs 1))
)

 

  

0 Likes