Author Topic: Scale a block relative to viewport  (Read 5831 times)

0 Members and 1 Guest are viewing this topic.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Scale a block relative to viewport
« on: March 29, 2005, 03:48:30 AM »
I am trying to ensure certain blocks are always the same plotted size, no-matter what the scale of the viewport is.

We use north arrows on virtually every drawing, and each user has their own idea of the size it should be.

What I would like is

To be able to "grab" the viewport scale.
To insert the north arrow at say 5% of the frame size (I think)
Allow the user to position the north arrow at a suitable location.

Any help would be much appreciated.

Many thanks
Thanks for explaining the word "many" to me, it means a lot.

hudster

  • Gator
  • Posts: 2848
Scale a block relative to viewport
« Reply #1 on: March 29, 2005, 04:43:53 AM »
I do something similar, but I user the userr1 variable, so on the custom menus I wrote I have a setup an option with a line containing the following

Code: [Select]
[1: 100]^C^C_setvar userr1 100

I then insert the blocks setting the scale as per the userr1 value, as per this code.

Code: [Select]
[62(P002,Switched Socket)]^c^c(setq old (getvar "clayer"))$M=$(if,$(=,$(getvar,tilemode),0),_pspace,_r) _attdia 1 _-layer _t;_62_SM_POW;_m _62_SM_POW;_c BLUE _62_SM_POW;;_-insert "P002" _xscale $(if,$(=,$(getvar,tilemode),0),1,$(getvar,userr1)) _yscale $(if,$(=,$(getvar,tilemode),0),1,$(getvar,userr1)) _zscale $(if,$(=,$(getvar,tilemode),0),1,$(getvar,userr1)) \\_-layer _s !old;;
Revit BDS 2017, 2016, 2015, 2014, AutoCAD 2017, 2016, Navisworks 2017, 2016, BIM360 Glue

CADaver

  • Guest
Scale a block relative to viewport
« Reply #2 on: March 29, 2005, 07:46:13 AM »
Shhhh...
Place ALL annotation, including North arrows in PS at a scale of 1

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Scale a block relative to viewport
« Reply #3 on: March 29, 2005, 07:54:12 AM »
:lol:
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

daron

  • Guest
Scale a block relative to viewport
« Reply #4 on: March 29, 2005, 07:56:21 AM »
Of course, that may not be an option.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Scale a block relative to viewport
« Reply #5 on: March 29, 2005, 11:30:26 AM »
Quote from: CADaver
Shhhh...
Place ALL annotation, including North arrows in PS at a scale of 1

No can do I'm afraid. North Arrows must be in the model. Usually the jobs have many viewports, usually rotated (with differant rotations) so the road is horizontal to the page. It would be difficult for the part-time cad users to figure out which way is north, then rotate the arrow to the correct alignment. North would always be up no matter how the viewport had been rotated :lol:
Thanks for explaining the word "many" to me, it means a lot.

CADaver

  • Guest
Scale a block relative to viewport
« Reply #6 on: March 29, 2005, 03:21:36 PM »
Quote from: jonesy
No can do I'm afraid. North Arrows must be in the model. Usually the jobs have many viewports, usually rotated (with differant rotations) so the road is horizontal to the page. It would be difficult for the part-time cad users to figure out which way is north, then rotate the arrow to the correct alignment. North would always be up no matter how the viewport had been rotated :lol:


??? ... ummm... drafters don't know which way North is??  But they're gonna work with rotated viewports???

???

okay.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Scale a block relative to viewport
« Reply #7 on: March 29, 2005, 04:08:29 PM »
Quote from: CADaver
??? ... ummm... drafters don't know which way North is??  But they're gonna work with rotated viewports???

???

okay.


Believe me it happens
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Scale a block relative to viewport
« Reply #8 on: March 29, 2005, 04:10:54 PM »
[psuedo code]  Do we know what viewport we are in?  if so, can we pull the scale value from that?
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Scale a block relative to viewport
« Reply #9 on: March 30, 2005, 03:10:27 AM »
Quote from: CADaver
Quote from: jonesy
No can do I'm afraid. North Arrows must be in the model. Usually the jobs have many viewports, usually rotated (with differant rotations) so the road is horizontal to the page. It would be difficult for the part-time cad users to figure out which way is north, then rotate the arrow to the correct alignment. North would always be up no matter how the viewport had been rotated :lol:


??? ... ummm... drafters don't know which way North is??  But they're gonna work with rotated viewports???

???

okay.


No, not the full-time cad user/drafters... The engineers who dont know how to read a base map! (Some of them rotate the bloody thing in model space to get the map to line up with the survey they have had done, and then cant figure out where North is. arggh :x  :x  :x I wish they would leave things alone. The times I have asked them to get the surveys done to the National Grid, then nothing needs to be moved or rotated in the model, but what do I know, I am only the Cad Monkey!
Thanks for explaining the word "many" to me, it means a lot.

CADaver

  • Guest
Scale a block relative to viewport
« Reply #10 on: March 30, 2005, 08:03:53 AM »
Quote from: jonesy
The engineers who dont know how to read a base map! (Some of them rotate the bloody thing in model space to get the map to line up with the survey they have had done, and then cant figure out where North is. arggh :x  :x  :x
Then that has nothing to do with paperspace annotation. Cuz' if a guy doesn't know which way is North, a rotated viewport will fry him.  And an Auto-Inserting North Arrow is noodled if the base map has been rotated.  It seems there are other issues here that need to be resolved before embarking on such an auto-Insertion function.

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Scale a block relative to viewport
« Reply #11 on: March 30, 2005, 08:20:16 AM »
OK Mr Cadaver, I'll agree with you :D

Our company standards are to annotate in model. This is made easier than it sounds as we only work in 2D. I know you are big in the "annotate in paper" brigade, but company standards are company standards, so we must annotate in the model!

So, unfortunately, my question still remains open.

Any ideas?
Thanks for explaining the word "many" to me, it means a lot.

ronjonp

  • Needs a day job
  • Posts: 7529
Scale a block relative to viewport
« Reply #12 on: March 30, 2005, 09:33:10 AM »
Jonesy,

Here is a "frankensteined" version. It will grab the twist angle of the viewport and the scale. It applies the twistangle to the rotation of the block and uses the viewport scale for the scale of the block. This way the north arrow will always be the same plotted size.

Ron

Code: [Select]
(defun c:N-ROT (/ ent obj twist scale pt)

(vl-load-com)
(setvar 'tilemode 0)

  (setq ent (entsel "\nSelect viewport: "))
  (setq obj (vlax-ename->vla-object (car ent)))
  (setq twist (vlax-get obj 'TwistAngle))
  (setq scale (vlax-get obj 'CustomScale))
  (setq scale (/ 1 scale))
  (setq twist (/ (* twist 180) pi))

(setvar 'tilemode 1)
  (initget 1)
  (setq pt (getpoint "\nPick North Arrow location"))
(command
  ".-INSERT"
  "north.dwg"  ;change this line to the path where your north
                      ;block resides example: C:\\blocks\\north.dwg
  pt

  1
  1
  twist
  )
)


*edit* I was playing around with this a little more an realized that if a viewport is twisted and you place the arrow in modelspace....it will correspond to the twist angle  :oops: duh. So this would be good for inserting the north arrow in paperspace or change the roatation angle to 0 if you want to insert it in model.

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

ronjonp

  • Needs a day job
  • Posts: 7529
Scale a block relative to viewport
« Reply #13 on: March 30, 2005, 10:24:52 AM »
Try this one for modelspace block insert:

We put all of our north arrows in paperspace. the routine above should make it pretty easy to "know" where north is.....assuming north is the same as the twist angle of the viewport.

Code: [Select]
(defun c:N-ROT (/ ent obj twist scale pt)

(vl-load-com)
(setvar 'tilemode 0)

  (setq ent (entsel "\nSelect viewport: ")
        obj (vlax-ename->vla-object (car ent))
  )

  (setq twist (vlax-get obj 'TwistAngle)
        scale (vlax-get obj 'CustomScale)
        scale (/ 1 scale);edit this line to adjust size of block
        twist (/ (* twist 180) pi)
  )

(setvar 'tilemode 1)

  (initget 1)
  (setq pt (getpoint "\nPick North Arrow location"))
(command
  ".-INSERT"
  "north.dwg"  ;change this line to the path where your north
                      ;block resides example: C:\\blocks\\north.dwg
  pt
  scale
  scale
  0
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Scale a block relative to viewport
« Reply #14 on: March 30, 2005, 10:59:18 AM »
Thanks for your help. It was just what I wanted.

I will look at the coding to see if I can figure out what is doing what.

Kind regards
Thanks for explaining the word "many" to me, it means a lot.

ronjonp

  • Needs a day job
  • Posts: 7529
Scale a block relative to viewport
« Reply #15 on: March 30, 2005, 11:20:16 AM »
Glad to of helped :). let me know if you need anything else.

Ron

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC