How to get a dimension's linear scale using LISP

Hello. I want to write a lisp that will detect all paper space dimensions that do not have the linear scale that matches the viewport that they relate to. Funny enough, I just cant find where the dimension linear scale data is kept in the dimension entity.

Please can someone tell me where the linear scale data is kept in the dimension entity ?

Comments

  • Anthony Apostolaros
    edited July 2023
    I might not understand you. I don't put dimensions in paperspace. If I did, I'd scale them all the same, regardless of which viewport they're associated with. They'd all have "Dim scale overall" = 1.

    I do give them different scales in modelspace, so that they'll look right in the viewports. I set their "Dim scale overall" property equal to the inverse of the viewport's scale. That makes them all look the same as a dimension in paperspace whose DSO = 1.

    But if that's what you're talking about, "Dim scale overall" is an ActiveX property called "ScaleFactor." It can be read with (vlax-get-property object "ScaleFactor") and written with (vla-put-scalefactor). Maybe other ways too, but that's what I stumbled onto.

    In case it helps, I'm attaching the lisp code for a custom command called SF that offers to change the ScaleFactor of all dimensions and leaders in a selection set, after first displaying the ScaleFactor of the oldest one.

    The attached DumpPM command lists all of an object's ActiveX properties and methods, with an (RO) after any property that can't be altered by code.
  • Overrides are stored in Xdata:
    (entget (car (entsel)) '("*"))
  • My memory is vague on this, but I think I had written years ago, asking if there was a way to indicate dimensions in that situation, so that their values were not to be trusted. I think someone had written a LISP routine to automatically find those dimensions and then flag them by changing their color. It may have worked by checking if the dimension had is associativity set to 2, which means it should be showing the true value.
  • Found the thread. And it included a routine by Roy Klein Gebbinck (don't use the 1st version posted)
    https://forum.bricsys.com/discussion/comment/27034#Comment_27034

    -Joe
  • I might not understand you. I don't put dimensions in paperspace. If I did, I'd scale them all the same, regardless of which viewport they're associated with. They'd all have "Dim scale overall" = 1.

    I do give them different scales in modelspace, so that they'll look right in the viewports. I set their "Dim scale overall" property equal to the inverse of the viewport's scale. That makes them all look the same as a dimension in paperspace whose DSO = 1.

    But if that's what you're talking about, "Dim scale overall" is an ActiveX property called "ScaleFactor." It can be read with (vlax-get-property object "ScaleFactor") and written with (vla-put-scalefactor). Maybe other ways too, but that's what I stumbled onto.

    In case it helps, I'm attaching the lisp code for a custom command called SF that offers to change the ScaleFactor of all dimensions and leaders in a selection set, after first displaying the ScaleFactor of the oldest one.

    The attached DumpPM command lists all of an object's ActiveX properties and methods, with an (RO) after any property that can't be altered by code.

    With Drawing Views I have to dimension in paper space and the linear dimension has to match the drawn view. So if the viewport is set to 1:16 i have to set the linear scale to 1:16 see image. But Associativity gets broken a lot and things get rescaled and drawings go to the workshop with wrong dimensions. I want to make a code that will pick up errors.

    I didn't think of vla- code. I'll have a look and see if there is a vle-get-property scaleliear or some such thing.
  • Found the thread. And it included a routine by Roy Klein Gebbinck (don't use the 1st version posted)
    https://forum.bricsys.com/discussion/comment/27034#Comment_27034

    -Joe

    Thanks for the link. I do have a code that detects and changes the colour of unassociated dimensions. I think that the problem is that I don't think associativity picks up drawing view scale changes. Also my associations are forever breaking so there are sometimes too many to repair in reasonable time.
  • Joe Dunfee
    edited August 2023
    In my tests just now on BricsCAD v14, if the drawing is scaled, the values of the dimensions stay correct. This is true whether the viewport itself is scaled, or the user zooms in/out while working inside a viewport. This was all tested without selecting any of the paperspace dimensions.

    I was surprised at how well this worked. I know I tested the paperspace dimensions years ago, and abandoned the idea, because there were ways to create dimensions that were not associative, and so the values were wrong. But, it would not be obvious.

    -Joe
  • Anthony Apostolaros
    edited August 2023
    DFLY said:

    ... if the viewport is set to 1:16 I have to set the linear scale to 1:16 ....

    I never knew about "Dim scale linear" before. Very useful. I should have tried DumpPM on a dimension entity before my earlier reply.

    So you could filter the selection set for dimension entities only (not leaders too, as in my SF command), then prompt the user to pick a viewport (or maybe re-use the selection set, filtering it this time for viewports?), then get its scale, maybe with (vlax-get-property object "CustomScale"), then calculate the inverse of that, and use (vla-put-LinearScaleFactor) to make that the "Dim scale linear" of all the dimensions selected.