Author Topic: Universal Scale funtion  (Read 2749 times)

0 Members and 1 Guest are viewing this topic.

Crank

  • Water Moccasin
  • Posts: 1503
Universal Scale funtion
« on: October 15, 2005, 04:10:06 AM »
In most of my routines I call a function to draw to the active scale. This is now very basic:
Code: [Select]
(defun b=sch (/ sch)
(if (eq (getvar "DIMSCALE") 0)
(setq sch 1.0)
(setq sch (getvar "DIMSCALE"))
)
)
When I've switched tabs I must make the right dimstyle active to let routines react as I want them to. There are several ways to improve this:
    [1]Always use a scale of 1 when you are in Paperspace
    [2]Make a reactor that makes the last used dimstyle active in modelspace or paperspace.
    [3]  ,,    ,,    ,,       ,,      ,,      ,,    ,,    ,,      ,,            ,,  for each tab.
   

Option 1 only works with a layout scale of 1. This works for our drawing standards, but not for all drawings we get from our clients.
Option 2 Is what I can do: make 2 reactors. When you switch dimstyle then store the dimstyle+space in a dictionary, and when you switch tabs restore the dimstyle that is stored in the dictionary.
Option 3 This is the best option, because it's possible to use different scales and dimstyles for each layout. This has to be done like option 2, but I think in this case you should use XDATA that is attached to the layout tab, because layouts can be renamed/deleted.

My problem is that I don't know how to read/write xdata to a tab. Is this possible? Is so how

Or do you have a different solution that I didn't think of?
« Last Edit: October 15, 2005, 04:14:42 AM by Crank »
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Universal Scale funtion
« Reply #1 on: October 15, 2005, 12:55:12 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Universal Scale funtion
« Reply #2 on: October 15, 2005, 02:25:43 PM »
8-) Forgot about that one. Looks like I have to do some studying :)

Thanks (and sourdoug for the code ).
Vault Professional 2023     +     AEC Collection

Crank

  • Water Moccasin
  • Posts: 1503
Re: Universal Scale funtion
« Reply #3 on: October 16, 2005, 10:11:14 AM »
Well, I've looked at the code, but that wasn't much help, I'm afraid. :(

What I had in mind to do was to attach XDATA to each tab.
Because I don't know how to do that, I'll use the dictionary option. Perhaps with some extra's for new or renamed tabs.
Vault Professional 2023     +     AEC Collection

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Universal Scale funtion
« Reply #5 on: October 16, 2005, 11:18:00 AM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Universal Scale funtion
« Reply #6 on: November 17, 2005, 09:41:15 AM »
This is what I was looking for:
Code: [Select]
(setq CLAYOUT (vlax-vla-object->ename (vla-get-activelayout (vla-get-activedocument (vlax-get-acad-object)))))Perhaps it can be done easier, but this works for me. :)
The xdata with the active dimstyle is attached to the layout, and it's also possible to read this data back when you change tabs.

So when you've got the name of dimstyle, it seems easy to restore that dimstyle. However when you try to do this from a reactor nothing happens....
The variable DIMSTYLE is read-only, and (vl-cmdf ".dim1" "restore" ds) or (vl-cmdf ".-dimstyle" "restore" ds) doesn't work.
What am I doing wrong? Or is it not possible to change the dimstyle with a reactor?

Attached is the very rough code I have so far...

Any improvements/suggestions are welcome!
« Last Edit: November 17, 2005, 09:47:11 AM by Crank »
Vault Professional 2023     +     AEC Collection

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Universal Scale funtion
« Reply #7 on: November 17, 2005, 09:32:06 PM »
suggestions ?

suggestion 1)
if you are using 2006, insert a field on each tab who was linked with dimstyle
and make a lisp to read this field before making dimension.

suggestion 2)
same as suggestion 1 but with block containing invisible attribute that you can read.

Suggestion 3)
rename your TAB like 1-(nametab), 2-(nametab)....
so you can detect someting like this....
Code: [Select]
(if (vl-string-search "1-" (getvar "ctab")) (vl-cmdf "_-dimstyle".......))
also you can have a list of all your paper layout with...(layoutlist)

hope this was helpful ^-^

don't forget to parameter the METRIC and IMPERIAL value...
for my own..I use this..

Code: [Select]
(if (> (getvar "LUNITS") 2)
(setq scalef 0.039380078)
(setq scalef 1)
)

so you can use dimscale and textsize with scalef
but if you prefer...I have wrote a lisp program who detect the vportscale and readjust the scalef variable depending if you are in METRIC or IMPERIAL in a VPORT or NOT etc...
« Last Edit: November 17, 2005, 09:38:53 PM by Andrea »
Keep smile...

Crank

  • Water Moccasin
  • Posts: 1503
Re: Universal Scale funtion
« Reply #8 on: November 18, 2005, 04:45:11 AM »
Andrea,

I didn't use (hidden) objects in each tab, because before you know it, they are copied or erased.
XDATA attached to the tab seems the best solution. When the dimstyle changes, the data is just replaced.

To use FIELDs is a interesting approach though: you don't need 2 reactors anymore.

Although we only make METRIC drawings, a scale factor for IMPERIAL drawings is a good idea. Thanks.
But why don't use (setq scalef (/ 1.0 25.4)) ? That's more exact.

-------------------------------
To repeat myself :) : I don't have any problems with saving or reading the dimstyle, but I can't restore the dimstyle from the reactor.
Vault Professional 2023     +     AEC Collection