+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Forum Newbie
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Jul 2017
    Posts
    9

    Default VBA Autocad: How to find lines?

    Registered forum members do not see this ad.

    I'm trying to write a VBA code that searches in a general drawing all lines that have a specific length and slope. Then, every time it finds that line in the drawing, it will write next to a specific text, for example "line". Do you think it's possibile? Any idea? Thanks

  2. #2
    Super Member Tyke's Avatar
    Computer Details
    Tyke's Computer Details
    Operating System:
    Windows 7 - 64 bit, W8 + W8.1 Vista
    Computer:
    HP Z400 Workstation
    CPU:
    Intel(R) Xeon(R) CPU W3530 @ 2.80GHz
    RAM:
    8 GB
    Graphics:
    Nvidia Quadro 600 1GB DDR3
    Primary Storage:
    2x 500GB HDD RAID 1 and Western Digital 2TB NAS RAID 1
    Secondary Storage:
    Lacie external HDD 2TB Raid Level 1
    Monitor:
    Samsung SyncMaster P2770HD, 2443 and 193T
    Discipline
    Multi-disciplinary
    Tyke's Discipline Details
    Occupation
    Surveyor, programmer, civil engineer
    Discipline
    Multi-disciplinary
    Details
    Surveying and civil engineering. As built utilities surveys and data maintenance in GIS systems. Building surveys, measured and laser scanning. Setting out of all civil works. Control and settlement surveys. Programming in AutoCAD, MicroStation, Geograf and stand alone applications for all uses.
    Using
    Civil 3D 2014
    Join Date
    Jun 2006
    Location
    Saxony, Germany
    Posts
    1,397

    Default

    In principle what you want to do is perfectly possible.

    You search the current drawing filtering on lines to create a selection set. Then loop through the selection set and write your text at your desired position.
    Engage brain before mouth

    "The German who types with a Yorkshire accent" - Dave Broada 2o1o

  3. #3
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    As VBA

    Code:
    Dim FilterDXFCode(0) As Integer
    Dim FilterDXFVal(0) As Variant
     
    FilterDXFCode(0) = 0
    FilterDXFVal(0) = "LINE"
     
     
    Set SS = ThisDrawing.SelectionSets.Add("Linelens")
    SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal
    For Cntr = 0 To SS.Count - 1
     
    'now get the length etc and do something
    As lisp
    Code:
    (setq ss (ssget (list (cons 0 "Line"))))
    (repeat (setq x (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname  ss (setq x (- x 1)))))
    (vla-get-length obj)
    (princ "\n")
    )
    A man who never made mistakes never made anything

  4. #4
    Senior Member
    Using
    AutoCAD 2009
    Join Date
    Oct 2012
    Posts
    293

    Default

    Quote Originally Posted by ElCidCampeador View Post
    Do you think it's possibile?
    Can.
    Write all the requirements, and attach an example.

  5. #5
    Forum Newbie
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Jul 2017
    Posts
    9

    Default

    Thank you all! It works...!

  6. #6
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,815

    Default

    What worked ? You dont have to post the code just how, others may want the same answer.
    A man who never made mistakes never made anything

  7. #7
    Forum Newbie
    Discipline
    Mechanical
    Using
    AutoCAD 2015
    Join Date
    Jul 2017
    Posts
    9

    Default

    Registered forum members do not see this ad.

    I used your idea Bigal, vba

Similar Threads

  1. Cant find lines in block
    By byk3bep in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 11th Feb 2016, 01:50 pm
  2. Find unsnapped lines
    By cmscardoso in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 7th Mar 2014, 05:08 pm
  3. find intersection of 3D lines
    By giskumar in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 7th Jan 2013, 12:58 am
  4. Replies: 6
    Last Post: 13th Jul 2011, 02:19 pm
  5. find crossing lines and break them down
    By epsi1on in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 22nd Apr 2011, 11:42 pm

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