+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 22
  1. #1
    Super Member stevsmith's Avatar
    Computer Details
    stevsmith's Computer Details
    Operating System:
    Windows 7 (64bit)
    Discipline
    Mechanical
    stevsmith's Discipline Details
    Occupation
    High Plains Drifter
    Discipline
    Mechanical
    Using
    Solidworks 2015
    Join Date
    Apr 2008
    Location
    Largs, Scotland
    Posts
    1,072

    Default Block into multileader text

    Registered forum members do not see this ad.

    I would like to try and set up a Multileader that reads the description of a block.

    For example when I am making the block I would like to put some descriptive text that may say "Post top insert connected to haboe pin"

    After the block is compelted and placed into a new drawing I would then select the multi leader option and then it would automtically fill in the text. (from the pre-defined description)

    I would like it to be similar to a callout in solidworks.
    "The fear of death follows from the fear of life. A man who lives fully is prepared to die at any time"

    SolidWorks | AutoCAD | Creo

  2. #2
    Super Member stevsmith's Avatar
    Computer Details
    stevsmith's Computer Details
    Operating System:
    Windows 7 (64bit)
    Discipline
    Mechanical
    stevsmith's Discipline Details
    Occupation
    High Plains Drifter
    Discipline
    Mechanical
    Using
    Solidworks 2015
    Join Date
    Apr 2008
    Location
    Largs, Scotland
    Posts
    1,072

    Default

    similar to this
    Attached Images
    "The fear of death follows from the fear of life. A man who lives fully is prepared to die at any time"

    SolidWorks | AutoCAD | Creo

  3. #3
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    not too terribly difficult:
    Code:
    (defun c:TEST (/ #Entsel #InsPoint #Name #Desc #LandPoint)
      (if (setq
            #Entsel (AT:Entsel nil "\nSelect block: " '((0 . "INSERT")) nil)
          ) ;_ setq
        (progn
          ;; convert to vla-object
          (setq #Entsel   (vlax-ename->vla-object (car #Entsel))
                ;; insertion point
                #InsPoint (vlax-safearray->list
                            (vlax-variant-value
                              (vla-get-InsertionPoint #Entsel)
                            ) ;_ vlax-variant-value
                          ) ;_ vlax-safearray->list
                ;; block name
                #Name     (vla-get-name #Entsel)
                ;; block description
                #Desc     (vla-get-comments
                            (vla-item
                              (vla-get-blocks
                                (vla-get-activedocument (vlax-get-acad-object))
                              ) ;_ vla-get-blocks
                              #Name
                            ) ;_ vla-item
                          ) ;_ vla-get-comments
          ) ;_ setq
          (cond
            ;; no description in block
            ((eq "" #Desc)
             (princ (strcat "\nNo description for block: \""
                            #Name
                            "\""
                    ) ;_ strcat
             ) ;_ princ
            )
            ;; specify leader landing location
            ((setq #LandPoint
                    (getpoint #InsPoint
                              "\nSpecify leader landing location: "
                    ) ;_ getpoint
             ) ;_ setq
             (vl-cmdf "_.mleader" "_non" #InsPoint "_non" #LandPoint #Desc)
            )
          ) ;_ cond
        ) ;_ progn
      ) ;_ if
      (princ)
    ) ;_ defun
    you'll need this subroutine:
    Code:
    ;;; Entsel or NEntsel with options
    ;;; #Nested - Entsel or Nentsel (T for Nentsel, nil for Entsel)
    ;;; #Message - Selection message (if nil, "\nSelect object: " is used)
    ;;; #FilterList - DXF ssget style filtering, no cons (nil if not required)
    ;;; #Keywords - Keywords to match instead of object selection (nil if not required)
    ;;; Example: (AT:Entsel nil "\nSelect MText not on 0 layer [Settings]: " '((0 . "MTEXT")(8 . "~0")) "Settings")
    ;;; Alan J. Thompson, 04.16.09
    ;;; Updated: Alan J. Thompson, 06.04.09 (changed filter coding and added layer option)
    (defun AT:Entsel (#Nested     #Message    #FilterList #Keywords
                      /           #Count      #Message    #Choice
                      #Ent
                     )
      (setvar "errno" 0)
      (setq #Count 0)
      (or #Message (setq #Message "\nSelect object: "))
      (if #Nested
        (setq #Choice nentsel)
        (setq #Choice entsel)
      ) ;_ if
      (while (and (not #Ent)
                  (/= (getvar "errno") 52)
             ) ;_ and
        (and #Keywords (initget #Keywords))
        (cond
          ((setq #Ent (#Choice #Message))
           (and
             #FilterList
             (vl-consp #Ent)
             (or
               (not
                 (member
                   nil
                   (mapcar
                     '(lambda (x)
                        (wcmatch
                          (if
                            (eq
                              (type
                                (cdr (assoc (car x) (entget (car #Ent))))
                              ) ;_ type
                              'STR
                            ) ;_ eq
                             (strcase
                               (cdr (assoc (car x) (entget (car #Ent))))
                             ) ;_ strcase
                             (cdr (assoc (car x) (entget (car #Ent))))
                          ) ;_ if
                          (cdr x)
                        ) ;_ wcmatch
                      ) ;_ lambda
                     #FilterList
                   ) ;_ mapcar
                 ) ;_ member
               ) ;_ not
               (setq #Ent nil)
             ) ;_ or
           ) ;_ and
          )
        ) ;_ cond
        (and (= (getvar "errno") 7)
             (not #Ent)
             (setq #Count (1+ #Count))
             (prompt (strcat "\nNope, keep trying!  "
                             (itoa #Count)
                             " missed pick(s)."
                     ) ;_ strcat
             ) ;_ prompt
        ) ;_ and
      ) ;_ while
      #Ent
    ) ;_ defun

  4. #4
    Super Member stevsmith's Avatar
    Computer Details
    stevsmith's Computer Details
    Operating System:
    Windows 7 (64bit)
    Discipline
    Mechanical
    stevsmith's Discipline Details
    Occupation
    High Plains Drifter
    Discipline
    Mechanical
    Using
    Solidworks 2015
    Join Date
    Apr 2008
    Location
    Largs, Scotland
    Posts
    1,072

    Default

    What do I do with the second script?

    i get this error

    Select block: ; error: no function definition: VLAX-ENAME->VLA-OBJECT
    "The fear of death follows from the fear of life. A man who lives fully is prepared to die at any time"

    SolidWorks | AutoCAD | Creo

  5. #5
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by stevsmith View Post
    What do I do with the second script?

    i get this error

    Select block: ; error: no function definition: VLAX-ENAME->VLA-OBJECT
    just put it in the .lsp file with the other.

    i always forget to add (vl-load-com) because i have it it my startup file.

    here, i'll just put it together for you:
    Attached Files

  6. #6
    Super Member stevsmith's Avatar
    Computer Details
    stevsmith's Computer Details
    Operating System:
    Windows 7 (64bit)
    Discipline
    Mechanical
    stevsmith's Discipline Details
    Occupation
    High Plains Drifter
    Discipline
    Mechanical
    Using
    Solidworks 2015
    Join Date
    Apr 2008
    Location
    Largs, Scotland
    Posts
    1,072

    Default

    Thanks Alan.
    That is exactly what I'm looking for.

    I'm trying to learn lisp myself. Lee gave me hundreds of tutorials to muck around with, but I'm trying to get back into Solidworks to look for new employment, so the lisp has been sidelined just now.

    i thought that there was maybe an option in the cui or setup i could have changed to do this. But this lisp is everything Im looking for.

    Thanks again mate.
    "The fear of death follows from the fear of life. A man who lives fully is prepared to die at any time"

    SolidWorks | AutoCAD | Creo

  7. #7
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by stevsmith View Post
    Thanks Alan.
    That is exactly what I'm looking for.

    I'm trying to learn lisp myself. Lee gave me hundreds of tutorials to muck around with, but I'm trying to get back into Solidworks to look for new employment, so the lisp has been sidelined just now.

    i thought that there was maybe an option in the cui or setup i could have changed to do this. But this lisp is everything Im looking for.

    Thanks again mate.
    happy to help
    had a few minutes last night and i was curious how to access the comments on a block (took a little research).

    btw, this will exit and prompt you if the block does not have a description.

  8. #8
    Forum Newbie
    Computer Details
    seapea's Computer Details
    Operating System:
    Win 7 x64
    Using
    Civil 3D 2011
    Join Date
    Mar 2011
    Location
    Albuquerque, NM, US
    Posts
    2

    Default

    How about the block name? This lisp is great, I just want to do the name rather than desc. I've tryed hacking the lisp code with no success 'cause I have no idea what I'm doing. Could you guide me throught how to get the block name in the multileader. Thanks in advance.

  9. #9
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2013
    Join Date
    Apr 2008
    Posts
    6,199

    Default

    Quote Originally Posted by seapea View Post
    How about the block name? This lisp is great, I just want to do the name rather than desc. I've tryed hacking the lisp code with no success 'cause I have no idea what I'm doing. Could you guide me throught how to get the block name in the multileader. Thanks in advance.
    Code:
    (defun c:BNameLabel (/ obj lastentity ent)
      (vl-load-com)
      (if (setq obj (car (entsel "\nSelect block: ")))
        (if (eq (cdr (assoc 0 (entget obj))) "INSERT")
          (progn (setq lastentity (entlast))
                 (vl-cmdf "_.mleader"
                          "_non"
                          (trans (vlax-get (setq obj (vlax-ename->vla-object obj)) 'InsertionPoint) 0 1)
                          PAUSE
                 )
                 (while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (vl-cmdf ""))
                 (if (not (equal lastentity (setq ent (entlast))))
                   (vla-put-textstring
                     (vlax-ename->vla-object ent)
                     (vlax-get-property
                       obj
                       (if (vlax-property-available-p obj 'EffectiveName)
                         'EffectiveName
                         'Name
                       )
                     )
                   )
                 )
          )
          (princ "\nInvalid object!")
        )
      )
      (princ)
    )
    DropBox
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  10. #10
    Forum Newbie
    Computer Details
    seapea's Computer Details
    Operating System:
    Win 7 x64
    Using
    Civil 3D 2011
    Join Date
    Mar 2011
    Location
    Albuquerque, NM, US
    Posts
    2

    Default re: Block into multileader test

    Registered forum members do not see this ad.

    I'm impressed with your quick reply. thanks

    ok, i run rhe lsp, select the block, see "abc", click to 'Specify opposite corner:', and it all goes away! What am I missing? Does this code go into the other lisp file test.lsp? confused

Similar Threads

  1. Leader/text to multileader
    By pmcwilliams in forum AutoCAD General
    Replies: 11
    Last Post: 30th Aug 2017, 04:26 pm
  2. Multileader with block content
    By dinarele in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 18th Aug 2009, 03:07 pm
  3. Multileader text
    By alijahed in forum AutoCAD General
    Replies: 5
    Last Post: 2nd Mar 2009, 09:58 am
  4. Cannot Edit Multileader Text
    By rustysilo in forum AutoCAD General
    Replies: 7
    Last Post: 2nd Feb 2009, 04:38 pm
  5. Multileader text at arrowhead end?
    By bbohannon1 in forum AutoCAD General
    Replies: 0
    Last Post: 13th Oct 2008, 07:11 pm

Bookmarks

Posting Permissions

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