Macro needed to speed up creating Named Views

Macro needed to speed up creating Named Views

brendon_butler
Enthusiast Enthusiast
1,960 Views
13 Replies
Message 1 of 14

Macro needed to speed up creating Named Views

brendon_butler
Enthusiast
Enthusiast

Hi,
Im wanting to speed up the creation of multiple Named Views.
Currently, I have the following macro working at the moment: *^C^C-view;w; (which simply runs the command and prompts for window selection, view name and then repeats). 
But, I want to expand on this a little to include the prompt for pick text of a numeric text object within my drawing to return as my View name, instead of entering the number manually.

Any help would be much appreciated!

0 Likes
Accepted solutions (1)
1,961 Views
13 Replies
Replies (13)
Message 2 of 14

pbejse
Mentor
Mentor

@brendon_butler wrote:

Hi,
Im wanting to speed up the creation of multiple Named Views....


 

Why a macro?  Are you using LT?

is there an object identifying the view? ( block or polyline ) ?

 

Named View from Rectangle (hmsilva) <--- look here

 

 

0 Likes
Message 3 of 14

brendon_butler
Enthusiast
Enthusiast

Thanks for your reply!
I guess it doesn't need to be a Macro as such. However, I thought there might be a quick an easy way to create a command button via a Macro in CUI. Any alternative would be equally accepted.
To answer your question re object ID. Yes, there will be a single line text object (number) that will be the unique number identifier that I want as the View name.

0 Likes
Message 4 of 14

pbejse
Mentor
Mentor

@brendon_butler wrote:

To answer your question re object ID. Yes, there will be a single line text object (number) that will be the unique number identifier that I want as the View name.


 

I'm refering to the window view brendon. look into the link on my previous post. We can change the prompt for view name with a obejct selection.

 

 

0 Likes
Message 5 of 14

brendon_butler
Enthusiast
Enthusiast

Ahh sorry, I misunderstood!
No, I'm defining the window via 2x existing node points. That too could also be set in the command. To window using node osnap. But, not the end of the world, as I can set osnap beforehand if needs be.

0 Likes
Message 6 of 14

pbejse
Mentor
Mentor

@brendon_butler wrote:

Ahh sorry, I misunderstood!
No, I'm defining the window via 2x existing node points. That too could also be set in the command. To window using node osnap. But, not the end of the world, as I can set osnap beforehand if needs be.


 

(Defun C:namedViewSelect (/ viewnamenumber ll ur)
  (setq tlcmdecho (getvar "cmdecho"))
  (if
    (and
      (setq viewnamenumber
	     (Car (entsel "\nSelect string for numer prefix: ")
	     )
      )
      (setq viewnamenumber (Cdr (assoc 1 (entget viewnamenumber))))
      (numberp (Read viewnamenumber))
      (setq ll (getpoint "\nPick lower left corner: "))

      (setq ur (getcorner ll "\nPick upper righ corner: "))
    )
     (command "view"
	      "_W"
	      (strcat (vl-filename-base (Getvar 'dwgname))
		      "_"
		      viewnamenumber
	      )
	      ll
	      ur
     )
  )
)
0 Likes
Message 7 of 14

brendon_butler
Enthusiast
Enthusiast

That's pretty good. But, it's including my dwg name as a prefix, which I don't require. Can this string be removed to only have the selected text value only?  It otherwise works very well, thank you!

0 Likes
Message 8 of 14

pbejse
Mentor
Mentor
Accepted solution
(Defun C:namedViewSelect (/ viewnamenumber ll ur)
  (setq tlcmdecho (getvar "cmdecho"))
  (if
    (and
      (setq viewnamenumber
	     (Car (entsel "\nSelect string for numer prefix: ")
	     )
      )
      (setq viewnamenumber (Cdr (assoc 1 (entget viewnamenumber))))
      (setq ll (getpoint "\nPick lower left corner: "))

      (setq ur (getcorner ll "\nPick upper righ corner: "))
    )
     (command "view"
	      "_W"
	      viewnamenumber
	      ll
	      ur
     )
  )
)
0 Likes
Message 9 of 14

brendon_butler
Enthusiast
Enthusiast

Perfect! Thank you kindly.

0 Likes
Message 10 of 14

pbejse
Mentor
Mentor

@brendon_butler wrote:

Perfect! Thank you kindly.


You are welcome

 

Cheers 👊

 

0 Likes
Message 11 of 14

brendon_butler
Enthusiast
Enthusiast

Sorry, one more thing I just realised I need it to do. I need the command to repeat.
I thought I'd simply just add an asterisk in front of my command macro for this to work (*^C^C_namedViewSelect;)

But, the command doesn't run at all with this added.
Do you have a fix for this?

0 Likes
Message 12 of 14

pbejse
Mentor
Mentor

@brendon_butler wrote:

Do you have a fix for this?


change the IF to WHILE

  (if
    (and
      (setq viewnamenumber
	     (Car (entsel "\nSelect string for numer prefix: ")
	   .....
TO
  (while
    (and
      (setq viewnamenumber
	     (Car (entsel "\nSelect string for numer prefix: ") ...

	   

 

0 Likes
Message 13 of 14

brendon_butler
Enthusiast
Enthusiast

That's great, thank again!

0 Likes
Message 14 of 14

timothy_crouse
Collaborator
Collaborator

Hello, I was pointed here from another thread

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/need-a-lisp-to-create-named-views-an...

 

I need to create multiple named views all with the same category: 

"FN-[start number]", "FN-001", "FN-003" . . . .. . "FN-[end number], [category name]

 

Any chance someone could modify the lisp in this thread to do that?

 

Thank You

-Tim C.

0 Likes