Jump to content

select endpoint without mouse


Recommended Posts

Posted

hi all

 

i have given a task to make 500 layouts .

i gave each layout tab a number " say 1 to 500 "

and the same layout tab number is written in the center of the rectangle in mspace , which is to align in that tab, "say eg 450 tab should show rec with '450' text location " .

can some one make a scr/lisp so that ,if i just go to that layout tab and type the tab number then

1)it should automatically go in mspace find the text

2)align the rectangle around that text to the layout .

 

i reached the half way, but got stuck when align /zoom/select command asks to select the corner point of rectangle .

bcs that is only possible with mouse .

or iff some one can make some thing that can select corner without mouse,

only then scr/lisp can be Completed.

image.thumb.png.b2df30266b7c9065ce0995eb5fb400f5.png

 

Posted (edited)

Are you trying to align each tab view with the respective rectangle in mspace?

I would use excel or google sheets to create a script file using incremented coordinates with the zoom command. Here is an example history from command line:

: CTAB
New current value for CTAB <"Layout1">: 1
: MS
: z
Zoom:  In/Out/All/Center/Dynamic/Extents/Left/Previous/Right/Scale/Window/<Scale (nX/nXP)>: l
Lower left corner: 0,0
Enter zoom factor (nX/nXP), or view height <838'-6 171/256">: 1/1xp
: ps
: CTAB
New current value for CTAB <"1">: 2

 

this turns into a script line something like this, assuming horizontal spacing of 50 and 1:1 scale factor. (I didn't test, you should do you own manual commands and record what you type.

ctab 1 ms z l 0,0 1/1xp ps
ctab 2 ms z l 50,0 1/1xp ps
ctab 3 ms z l 100,0 1/1xp ps

 

I copy past the spreadsheet into a text file, use find & replace to convert tabs to spaces and run the script. Test just a couple lines are first until you get the bugs worked out. 
Here is a link to an example spreadsheet, modify the master row values

https://docs.google.com/spreadsheets/d/11c6L8t4QEAHq0Amzuwi7nk2mn2ctSfKl0OdKwn_821Q/edit?usp=sharing

Edited by dan20047
Posted
2 hours ago, dan20047 said:

Are you trying to align each tab view with the respective rectangle in mspace?

I would use excel or google sheets to create a script file using incremented coordinates with the zoom command. Here is an example history from command line:


: CTAB
New current value for CTAB <"Layout1">: 1
: MS
: z
Zoom:  In/Out/All/Center/Dynamic/Extents/Left/Previous/Right/Scale/Window/<Scale (nX/nXP)>: l
Lower left corner: 0,0
Enter zoom factor (nX/nXP), or view height <838'-6 171/256">: 1/1xp
: ps
: CTAB
New current value for CTAB <"1">: 2

 

this turns into a script line something like this, assuming horizontal spacing of 50 and 1:1 scale factor. (I didn't test, you should do you own manual commands and record what you type.


ctab 1 ms z l 0,0 1/1xp ps
ctab 2 ms z l 50,0 1/1xp ps
ctab 3 ms z l 100,0 1/1xp ps

 

I copy past the spreadsheet into a text file, use find & replace to convert tabs to spaces and run the script. Test just a couple lines are first until you get the bugs worked out. 
Here is a link to an example spreadsheet, modify the master row values

https://docs.google.com/spreadsheets/d/11c6L8t4QEAHq0Amzuwi7nk2mn2ctSfKl0OdKwn_821Q/edit?usp=sharing

 

 

Thanks for replying Dan..

but do we have something that snaps corner without mouse 🖱.? 

Posted

my solution is different than what you ask, as I don't have an easy answer to your exact request, and instead tried to guess at your bigger picture goal with tools I've used before. Given your task I would create a script to make all the viewports and align the view based on a system of coordinates for the rectangles in model space

 

Options for aligning viewports:

Zoom left

zoom > L (for left) > type coordinates > enter scale factor example 1/48xp

the left option is undocumented since release 14 (try it!)

 

Save view based on coordinates, then restore it in the viewport

-view > window > type view name say "1" or "2" > enter coordinates

in paperspace viewport

-view > restore > "1"

 

your exact request requires the following pseudo code:

ask for number

find text containing that number

process text, find nearest rectangle surrounding it (this is the hard part)

get coordinates of rectangle

set view to coordinates

Posted

I found another way to solve this, 

i used zoom2text lisp .

it will find the text string in dwg and zoom to it 

then zoom command ,

but now a new issue .

con someone help so that i dont have to type the tab number twice.....if i just type Ctab number once and zoom2txt takes ctab valve automatically. 

 

 

 

CTABzoomtotxt.lsp
New current value for CTAB <"454">: 455
: MS
: ZOOM2TXT
Enter text string to zoom to: 455
Search for embedded strings? <Y or N>: n
: _zoom
Zoom [zoom In/zoom Out/All/Center/Dynamic/Extents/Left/Previous/Right/Scale (nx/nxp)/Window/OBject] <Scale (nX/nXP)>:w
First corner:
Opposite corner:
Edit Text, text Properties or Neither? <T P N>: 
Cancel
; error : Function cancelled
: z
Zoom [zoom In/zoom Out/All/Center/Dynamic/Extents/Left/Previous/Right/Scale (nx/nxp)/Window/OBject] <Scale (nX/nXP)>:c
Center of view <689003.287,561002.817,0.000>
Enter zoom factor (nX/nXP), or view height <2.000>: 48
: -VPORTS
Viewports:  Set first corner or [ON/OFf/Lock/Fit/create 2 viewports/create 3 viewports/create 4 viewports/Object/Polygonal]:l
Viewport locking [ON/OFf] <ON>:
Select viewports [selection options (?)]:?
Select entities [select ALL entities/Add/add to set (+)/Remove/subtract from set (-)/Previous selection/Last entity in drawing/inside Window/Crossing window/Outside window/Window Polygon/Crossing Polygon/Outside Polygon/Window Circle/Crossing Circle/Outside Circle/Box/POint/Fence/AUto/Multiple/Single/select by PROperties.../selection methoDs.../Undo/Group]: b
First corner of selection box: 0,0
Opposite Corner: 402,248
Entities in set: 2
Select viewports [selection options (?)]:
: PS
: z
Zoom [zoom In/zoom Out/All/Center/Dynamic/Extents/Left/Previous/Right/Scale (nx/nxp)/Window/OBject] <Scale (nX/nXP)>:e

Posted

try adding these two lines noted below

  (if (= embed "Y")
    (setq txt (strcat "*" txt "*"))
  )
  ;; new code
  (setvar "ctab" txt)
  (command "mspace")
  ;; end new code
  (setq zoompt1 (getvar "extmin"))
  (setq zoompt2 (getvar "extmax"))

 

ps, please don't highlight the code, I use darkmode and can't read it easily

Posted

Why not just ssget text, make a new layout with that name, do mview, mspace, zoom c textinspt scale, pspace, lock viewport. Do next,  ie dont make layouts 1st.

 

This has advantage that when "layout new" can copy a master layout that has a title block.

 

I take it that the text has been created in sequence so the ssget will get 1-500 in order.

 

(defun c:wow ( / ss x val ins txt obj)

(setq ss (ssget "x" '((0 . "TEXT")(410 . "Model"))))

(setq x -1)
(repeat (sslength ss)

(setq txt (entget (ssname ss (setq x (1+ x)))))

(setq val (cdr (assoc 1 txt)))
(setq ins (cdr (assoc 10 txt)))

(command "layout" "C" "D01" val)
(setvar 'ctab val)
; If no mview here then do now
(command "mspace" "zoom" "C" ins 100)
(command "zoom" "4xp")
(command "pspace")
(setq vp (ssget "x" (list (cons 0  "VIEWPORT")(cons 410  val))))
(setq obj (vlax-ename->vla-object (ssname vp 0)))
(vla-put-DisplayLocked obj 1)
)

(princ)

)

 

 

 

 

 

 

Posted
On 04/11/2021 at 00:23, BIGAL said:

Why not just ssget text, make a new layout with that name, do mview, mspace, zoom c textinspt scale, pspace, lock viewport. Do next,  ie dont make layouts 1st.

 

This has advantage that when "layout new" can copy a master layout that has a title block.

 

I take it that the text has been created in sequence so the ssget will get 1-500 in order.

 


(defun c:wow ( / ss x val ins txt obj)

(setq ss (ssget "x" '((0 . "TEXT")(410 . "Model"))))

(setq x -1)
(repeat (sslength ss)

(setq txt (entget (ssname ss (setq x (1+ x)))))

(setq val (cdr (assoc 1 txt)))
(setq ins (cdr (assoc 10 txt)))

(command "layout" "C" "D01" val)
(setvar 'ctab val)
; If no mview here then do now
(command "mspace" "zoom" "C" ins 100)
(command "zoom" "4xp")
(command "pspace")
(setq vp (ssget "x" (list (cons 0  "VIEWPORT")(cons 410  val))))
(setq obj (vlax-ename->vla-object (ssname vp 0)))
(vla-put-DisplayLocked obj 1)
)

(princ)

)

 

 

 

 

 

 

sorry frnds 

 

i dont know making lisp yet , i am new....

i just know how to load lisp and make script.

 

for me this "wow" lisp is not working.

i copied the wow lisp and made a lsp file ,loaded it ,but not loading successfully.

Posted

I copied the wow lisp and made a lsp file ,loaded it ,but not loading successfully.

 

If you look at the code it expects at least 1 layout to exist and that layout has your title block and a mview set up. 

 

(command "layout" "C" "D01" val) so replace "D01" with the name of your layout. eg "Layout1" 

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