See the top rated post in this thread. Click here

Results 1 to 10 of 10

Thread: Lisp to to change dim scale linear to match auxilary scale

  1. #1
    I could stop if I wanted to
    Join Date
    2009-10
    Posts
    262
    Login to Give a bone
    0

    Default Lisp to to change dim scale linear to match auxilary scale

    Is there a lisp that will automate the dim linear scale to match the auxiliary scale...

    so if a dimension is represented four times larger then I want it to read I could

    Select dimension:

    Then the code would read the CANNO SCALE

    and change the Dim Linear Scale of selected object to reflect that

    Example included
    Attached Files Attached Files

  2. #2
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    412
    Login to Give a bone
    0

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    Try this as I work in metric its much easier to convert the cannoscale.

    Code:
    (defun c:candim ( / obj sc scf)
    (vl-load-com)
    (setq obj (vlax-ename->vla-object(car (entsel "pick dimension"))))
    (setq sc (getvar 'cannoscale))
    (cond
    ((= sc "1/4\" = 1'-0\"")(setq scf 0.25))
    ((= sc "1/2\" = 1'-0\"")(setq scf 0.5))
    )
    (vla-put-LinearScaleFactor obj scf)
    )
    Last edited by ahouston972454; 2015-08-07 at 07:54 AM.

  3. #3
    I could stop if I wanted to
    Join Date
    2009-10
    Posts
    262
    Login to Give a bone
    0

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    Thanks a lot I greatly appreciate it...

    I'm not very fluent in vlax for lisp...

    So is anyone will to help me apply a sort of ssget so this can apply to multiple dimensions at once.

  4. #4
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,483
    Login to Give a bone
    1

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    Quote Originally Posted by mbrandt5 View Post
    Thanks a lot I greatly appreciate it...

    I'm not very fluent in vlax for lisp...

    So is anyone will to help me apply a sort of ssget so this can apply to multiple dimensions at once.
    I'm assuming ahouston972454's code works on individually picked objects. I'm not testing it.

    There is one line in there which would needs some tweaking to make it work on multiple objects. Of course, you would need to also add another closed parenthesis near the end as you would want to loop through the selection set.

    So, let's tweak some code. The following code removes the ability to select a dimension. Instead, it now requires you to supply an entity name to perform the necessary changes. By doing this we now have a function that does one performs part of the overall routine you are asking someone to provide to you.

    Code:
    (defun _candim ( ent / obj sc scf)
      (vl-load-com)
      (setq obj (vlax-ename->vla-object ent))
      (setq sc (getvar 'cannoscale))
      (cond
        ((= sc "1/4\" = 1'-0\"")(setq scf 0.25))
        ((= sc "1/2\" = 1'-0\"")(setq scf 0.5))
      )
      (vla-put-LinearScaleFactor obj scf)
    )
    Of course, you are thinking, "I don't want less functionality from the previous code. I want more functionality added to it.

    Now that we have the simple minded task created, we can look at reusing that code to perform the task on multiple items.

    So, now, let's write some code to select a bunch of objects and execute the simple task on each item.
    Code:
    (defun c:candim ( / ss cnt )
      (setq ss (ssget '((0 . "DIMENSION")))) ; Select dimension entities
      (if (> (setq cnt (sslength ss)) 0)
        (repeat cnt
          (_candim (ssname ss (setq cnt (1- cnt))))
        )
      )
    )
    By separating out the tasks, we can then build routines as building blocks to make larger routines. Is this the most efficient code? Probably not. I didn't add anything to improve efficiency. However, the code does answer the additional request.

    Good Luck.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  5. #5
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    2

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    When iterating Selection Sets, I find it beneficial to iterate using the functions that handle the eName/vla-Object you ultimately want to query, or modify later in the code.

    As example, if using eName, try REPEAT or WHILE, whereas if needing vla-Object use VLAX-FOR in lieu of REPEAT/WHILE + VLAX-ENAME->VLA-OBJECT.



    Also, for LinearScaleFactor, consider CANNOSCALEVALUE in lieu of CANNOSCALE.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    8,483
    Login to Give a bone
    0

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    Good idea. What benefits have you discovered using the functions associated with each?

    In this instance, how would you handle an autolisp selection set as a collection to allow the usage of VLAX-FOR? The ActiveSelectionSet property of the Document object?
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    When dealing with Entity Names, or DXF I think it makes more sense to iterate an SSGET selection set using WHILE, or REPEAT, the latter being more efficient than the former.

    If I need to access a selected entity's VLA-OBJECT Properties (not everything about a given object is available to either DXF or ActiveX, unfortunately), then I use the ActiveDocument Object's ActiveSelectionSet Property Collection. This is more efficient than using REPEAT + VLAX-ENAME->VLA-OBJECT and allows for quick calls to START/ENDUNDOMARK as well.

    I'll post a slight adaptation to the code already posted here to demonstrate another time, particularly once this complementary bottle of Ozeki Nigori wears off. Haha

    Kampai!
    Last edited by BlackBox; 2015-08-21 at 06:16 PM. Reason: Spelling
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

  8. #8
    I could stop if I wanted to
    Join Date
    2003-07
    Posts
    412
    Login to Give a bone
    0

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    Thanks Black box the cannoscalevalue is the way to go rather than using a text description.

  9. #9
    I could stop if I wanted to
    Join Date
    2009-10
    Posts
    262
    Login to Give a bone
    0

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    When running that version Opie...it worked at first but now I'm getting this error

    ; error: ActiveX Server returned an error: Parameter not optional

    Any idea why?

  10. #10
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,536
    Login to Give a bone
    0

    Default Re: Lisp to to change dim scale linear to match auxilary scale

    Quote Originally Posted by BlackBox View Post
    I'll post a slight adaptation to the code already posted here to demonstrate another time....
    Code:
    (defun c:FOO (/ *error* acDoc scale ss)
    
      (defun *error* (msg)
        (if ss (vla-delete ss))
        (if acDoc (vla-endundomark acDoc))
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (if
        (ssget "_:L" '((0 . "DIMENSION")))
        (progn
          (vla-startundomark
            (setq acDoc (vla-get-activedocument (vlax-get-acad-object)))
          )
          (setq scale (getvar 'cannoscalevalue))
          (vlax-for x (setq ss (vla-get-activeselectionset acDoc))
            (vla-put-linearscalefactor x scale)
          )
        )
      )
    
      (*error* nil)
    )
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3620, Core i7-7700K 4.2GHz, 64GB RAM, Samsung 970 Pro M.2, 8GB NVIDIA Quadro P4000

Similar Threads

  1. match annotation scale to viewport scale
    By Mary_Ellen_Banning in forum AutoLISP
    Replies: 11
    Last Post: 2014-12-18, 03:20 AM
  2. 2014: Layout Line scale don't match
    By boyerd492098 in forum AutoCAD General
    Replies: 2
    Last Post: 2014-10-02, 07:40 PM
  3. Dim Linear Scale
    By tntdraftsol in forum AutoCAD Annotation
    Replies: 7
    Last Post: 2010-06-03, 09:35 PM
  4. match annotation scale to viewport scale
    By ccowgill in forum AutoLISP
    Replies: 33
    Last Post: 2009-05-04, 10:54 PM
  5. Lisp to change Dimstyle scale
    By margaretl in forum AutoLISP
    Replies: 14
    Last Post: 2007-08-02, 08:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •