+ Reply to Thread
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 21
  1. #1
    Full Member Luís Augusto's Avatar
    Discipline
    Electrical
    Luís Augusto's Discipline Details
    Occupation
    Designer / Planner
    Discipline
    Electrical
    Details
    Manufacture of electrical harnesses
    Using
    AutoCAD 2010
    Join Date
    Apr 2012
    Location
    Botucatu, SP, Brazil
    Posts
    80

    Default Select associated objects a field autocad

    Registered forum members do not see this ad.

    Hi guys, is there any command that performs the selection of objects associated with an object field?
    I'm using an excellent routine performed by Lee Mac to make the sum of texts. At the end of addition, it generates a field.
    In some moments I need to check the path where I spent. It would be very interesting if we could make a quick selection using the ID of the objects contained in the field.
    I should point out that I still have no experience with the Lisp language.
    Thank in advance.
    Luis Augusto.

    Currently with autocad 2010
    Translated by google

  2. #2
    Luminous Being BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    2 x 240GB Samsung EVO SSD (RAID 0)
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Discipline
    Civil
    BlackBox's Discipline Details
    Occupation
    Senior Civil Designer
    Discipline
    Civil
    Details
    Public/Private Land Development, Transportation, and Utilities.
    Using
    Civil 3D 2016
    Join Date
    Nov 2009
    Posts
    5,282

    Default

    You'll need to first parse the FieldCode string, and then iterate the appropriate Block Object given the ObjectId extracted.
    Last edited by BlackBox; 7th Jul 2013 at 06:35 pm.
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD, and Civil 3D Certified Professional | Autodesk Authorized Developer
    Sincpac C3D ~ Exchange Apps ~ Autoloader ~ AutoCAD Security

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,322

    Default

    See this old program:

    http://www.theswamp.org/index.php?topic=39951

    [ membership may be required ]
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  4. #4
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,049

    Default

    My try ...

    Code:
    (defun c:Test (/ ss i sn fd cd l s sad j e p n)
    ;;;        --=={ Tharwat 07. 07. 2013 }==--    ;;;
    ;;; Function to select the related Texts to a field     ;;;
      (if (progn
            (princ "\n Select field Text :")
            (setq ss (ssget "_+.:S" '((0 . "MTEXT"))))
          )
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (if (setq fd (vla-fieldcode (vlax-ename->vla-object sn)))
            (while
              (setq cd (vl-string-search "%<\\_ObjId " fd))
               (setq l  (cons (atoi (substr fd (+ cd 11) 10)) l)
                     fd (substr fd (+ cd 11))
               )
            )
          )
        )
      )
    
      (if
        (and l
             (setq
               s (ssget "_X"
                        (list '(0 . "TEXT,MTEXT") (cons 410 (getvar 'ctab)))
                 )
             )
        )
         (progn
           (setq sad (ssadd))
           (repeat (setq j (sslength s))
             (setq e (ssname s (setq j (1- j))))
             (if (member (vla-get-ObjectID (vlax-ename->vla-object e)) l)
               (ssadd e sad)
             )
           )
         )
      )
      (if (and sad (> (sslength sad) 0))
        (progn
          (setq p (cdr (assoc 10 (entget (ssname ss 0)))))
          (repeat (setq n (sslength sad))
            (grdraw p
                    (cdr (assoc 10 (entget (ssname sad (setq n (1- n))))))
                    2
                    1
            )
          )
        )
      )
      (princ)
    )
    (vl-load-com)

  5. #5
    Full Member Luís Augusto's Avatar
    Discipline
    Electrical
    Luís Augusto's Discipline Details
    Occupation
    Designer / Planner
    Discipline
    Electrical
    Details
    Manufacture of electrical harnesses
    Using
    AutoCAD 2010
    Join Date
    Apr 2012
    Location
    Botucatu, SP, Brazil
    Posts
    80

    Default

    Quote Originally Posted by BlackBox View Post
    You'll need to first parse the FieldCode string, and then iterate the appropriate Block Object given the handle (ObjectId) extracted.
    Dear BlackBox, thanks for the reply. Unfortunately still can not create my own codes. Hopefully soon get.

    Quote Originally Posted by Lee Mac View Post
    See this old program:

    http://www.theswamp.org/index.php?topic=39951

    [ membership may be required ]
    Lee, thanks for helping me again. Unfortunately I still have no access to www.theswamp.org. I sent an email to Mark to get access.

    Quote Originally Posted by Tharwat View Post
    My try ...

    Code:
    (defun c:Test (/ ss i sn fd cd l s sad j e p n)
    ;;;        --=={ Tharwat 07. 07. 2013 }==--    ;;;
    ;;; Function to select the related Texts to a field     ;;;
      (if (progn
            (princ "\n Select field Text :")
            (setq ss (ssget "_+.:S" '((0 . "MTEXT"))))
          )
        (repeat (setq i (sslength ss))
          (setq sn (ssname ss (setq i (1- i))))
          (if (setq fd (vla-fieldcode (vlax-ename->vla-object sn)))
            (while
              (setq cd (vl-string-search "%<\\_ObjId " fd))
               (setq l  (cons (atoi (substr fd (+ cd 11) 10)) l)
                     fd (substr fd (+ cd 11))
               )
            )
          )
        )
      )
    
      (if
        (and l
             (setq
               s (ssget "_X"
                        (list '(0 . "TEXT,MTEXT") (cons 410 (getvar 'ctab)))
                 )
             )
        )
         (progn
           (setq sad (ssadd))
           (repeat (setq j (sslength s))
             (setq e (ssname s (setq j (1- j))))
             (if (member (vla-get-ObjectID (vlax-ename->vla-object e)) l)
               (ssadd e sad)
             )
           )
         )
      )
      (if (and sad (> (sslength sad) 0))
        (progn
          (setq p (cdr (assoc 10 (entget (ssname ss 0)))))
          (repeat (setq n (sslength sad))
            (grdraw p
                    (cdr (assoc 10 (entget (ssname sad (setq n (1- n))))))
                    2
                    1
            )
          )
        )
      )
      (princ)
    )
    (vl-load-com)
    Tharwat, thanks for your reply.
    Unfortunately, the program did not work on my machine here, also did not return error.
    I am attaching the design to perform a test.
    I appreciate everyone's attention.

    SUM.dwg

    Luis Augusto.
    Translated by google

  6. #6
    Full Member Luís Augusto's Avatar
    Discipline
    Electrical
    Luís Augusto's Discipline Details
    Occupation
    Designer / Planner
    Discipline
    Electrical
    Details
    Manufacture of electrical harnesses
    Using
    AutoCAD 2010
    Join Date
    Apr 2012
    Location
    Botucatu, SP, Brazil
    Posts
    80

    Star

    Quote Originally Posted by Lee Mac View Post
    See this old program:

    http://www.theswamp.org/index.php?topic=39951

    [ membership may be required ]
    Beautiful job Lee.
    Congratulations. Not even in a dream could imagine something so perfect for my situation.
    This routine is fantastic, I run the commands zoom and pan, temporary lines keeps the same way.
    Surely the program will greatly improve my work.
    I can post the code for others with the same need to see the solution?

    Thank you all.

    Best regards,
    Luís Augusto.

    Translated by google
    Last edited by Luís Augusto; 8th Jul 2013 at 04:40 pm.

  7. #7
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,049

    Default

    Quote Originally Posted by Luís Augusto View Post

    Tharwat, thanks for your reply.
    Unfortunately, the program did not work on my machine here, also did not return error.
    I am attaching the design to perform a test.
    I appreciate everyone's attention.

    Luis Augusto.
    Translated by google
    That's odd , I tried the code on Cad 2010 and 2013 and it works well .

    The routine ask you to pick on field string then it will draw a vector line to the related text entities to that field .

    Are you using my code separately or you are adding them to another codes ?

  8. #8
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,322

    Default

    Quote Originally Posted by Luís Augusto View Post
    Beautiful job Lee.
    Congratulations. Not even in a dream could imagine something so perfect for my situation.
    This routine is fantastic, I run the commands zoom and pan, temporary lines keeps the same way.
    Surely the program will greatly improve my work.
    That's fantastic to hear, thank you for your kind compliments Luís!
    I'm delighted that the program will be useful in your work.

    Quote Originally Posted by Luís Augusto View Post
    I can post the code for others with the same need to see the solution?
    I have now attached the program to this post for those without access to the Swamp.

    FieldObjects.gif
    Attached Files
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  9. #9
    Full Member Luís Augusto's Avatar
    Discipline
    Electrical
    Luís Augusto's Discipline Details
    Occupation
    Designer / Planner
    Discipline
    Electrical
    Details
    Manufacture of electrical harnesses
    Using
    AutoCAD 2010
    Join Date
    Apr 2012
    Location
    Botucatu, SP, Brazil
    Posts
    80

    Default

    Quote Originally Posted by Tharwat View Post
    That's odd , I tried the code on Cad 2010 and 2013 and it works well .

    The routine ask you to pick on field string then it will draw a vector line to the related text entities to that field .

    Are you using my code separately or you are adding them to another codes ?
    Tharwat, I do not dare to change codes. I am trying to understand so many parentheses.
    Tomorrow i will test your routine on other machines and give you feedback.
    I believe that the forum users here could do the same, thus we would have two solutions.
    Thanks for disposal.

    Best Regards, Luis Augusto.

    Translated by google

  10. #10
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,049

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Luís Augusto View Post
    Tomorrow i will test your routine on other machines and give you feedback.
    I will be waiting for that test

    Thank you .

Similar Threads

  1. AutoCAD Pick Points and Select Objects
    By chickenjoe in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 7th May 2012, 06:25 am
  2. I have to shift-select to select multiple objects
    By PDS in forum AutoCAD Beginners' Area
    Replies: 16
    Last Post: 29th Nov 2011, 08:15 pm
  3. Select By Selection Set Name, on 'Select Objects:' prompt
    By harilalmn in forum AutoLISP, Visual LISP & DCL
    Replies: 15
    Last Post: 23rd Aug 2011, 10:28 am
  4. Use Quick Select to select objects in your AutoCAD drawing
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 16th Mar 2011, 04:29 pm
  5. Quickly select objects with Quick Select
    By AutoCAD Tips Blog in forum AutoCAD RSS Feeds
    Replies: 0
    Last Post: 23rd Dec 2007, 01:13 am

Tags for this Thread

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