Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Open Geometry

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
kylegoltsch
594 Views, 4 Replies

Open Geometry

I am running AutoCad 2000 and need to manipulate over 12,000 .dxf files.  I would like to automatically select all open geometries within a file and move them to a cetain layer.  Open geometry would be defined as "any entity that has a an end point that no other entity has".

 

A clear example of this would be 1 line that touches no other on at least 1 end.

 

I would like to add this to a lisp routine that I already have to automatically open, perform some work, save back as a dxf and overwrite the existing, close and open next dxf file , repeat until all files in a folder are complete.

 

Any help would be greatly appreciated!

4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: kylegoltsch


@kylegoltsch wrote:

....  I would like to automatically select all open geometries within a file and move them to a cetain layer.  Open geometry would be defined as "any entity that has a an end point that no other entity has".

 

A clear example of this would be 1 line that touches no other on at least 1 end.

 

I would like to add this to a lisp routine that I already have to automatically open, perform some work, save back as a dxf and overwrite the existing, close and open next dxf file , repeat until all files in a folder are complete.

....


This seems to do that, in limited testing.  [Of course, take the (defun) wrapper away from the beginning and end if you incoporate it into a longer routine.]  No error handling or saving/restoring the current Layer or CMDECHO control or any of that, yet.

 

(defun C:OGL (/ entlist ptlist pt con); = Open Geometry to its own Layer
  (vl-load-com)
  (command ; include only if the Layer might not already exist in all files
    "_.layer"
      "_make" "OpenGeometry" ; choose your Layer name
      "_color" 222 "" ; choose your color
      "_ltype" "divide2" "" ; choose your linetype
    "" ; finish Layer command
  ); end command
  (setq
    entlist
      (vl-remove-if ; eliminate any closed Polylines/Ellipses/Splines
        'vlax-curve-isClosed
        (mapcar 'cadr ; list of all possible entities' names
          (ssnamex (ssget "_X" '((0 . "LINE,ARC,*POLYLINE,ELLIPSE,SPLINE"))))
        ); end mapcar
      ); end vl-remove-if & entlist
  ); end setq
  (foreach ent entlist ; make list of all open-ended entity start & end points
    (setq
      ptlist (cons (vlax-curve-getStartPoint ent) ptlist)
      ptlist (cons (vlax-curve-getEndPoint ent) ptlist)
    ); end setq
  ); end foreach
  (foreach ent entlist
    (setq
      pt (vlax-curve-getStartPoint ent); check 1st end
      con (vl-remove-if-not '(lambda (x) (equal x pt 1e-4)) ptlist); choose your precision
        ; list of occurrences of the same point [more than once = connecting entity]
    ); end setq
    (if (= (length con) 1); no other entity start/end connects
      (command "_chprop" ent "" "_layer" "OpenGeometry" ""); then - change Layer
      (progn ; else - 1st end connects to something; check 2nd end
        (setq
          pt (vlax-curve-getEndPoint ent); 2nd end
          con (vl-remove-if-not '(lambda (x) (equal x pt 1e-4)) ptlist)
        ); end setq
        (if (= (length con) 1); no other entity start/end connects
          (command "_chprop" ent "" "_layer" "OpenGeometry" ""); then - change Layer
        ); end if [no else - do nothing if it connects at both ends]
      ); end progn - else - 2nd end
    ); end if
  ); end foreach
); end defun

Kent Cooper, AIA
Message 3 of 5
markruys2
in reply to: kylegoltsch

you should look into using objectdbx, it will do all your 12,000 files in a few minutes, but the catch is, it will loose the preview bitmaps.

 

Message 4 of 5
kylegoltsch
in reply to: Kent1Cooper

Did some extensive testing and it worked great.  I was able to incorporate it into my other lisp file that would open, close and save files.  

 

I look forward to running all 12,000 files.

 

Thanks so much for your help!

 

Kyle

Message 5 of 5
Kent1Cooper
in reply to: kylegoltsch


@kylegoltsch wrote:

Did some extensive testing and it worked great.  I was able to incorporate it into my other lisp file....

I look forward to running all 12,000 files.

....


As "a person of a certain age," I can't help but think of that early-1960's folk/campfire classic, recorded by The Journeymen, the Kingston Trio, Peter Paul & Mary, and many others:

 

"....

12,000 files, 12,000 files, 12,000 files, 12,000 files,

You can make the function fix 12,000 files!

...."
 

 

 
[For instance: http://www.bing.com/videos/search?q=500+miles&mid=CD650A530AAFBDE7A210CD650A530AAFBDE7A210&view=deta...]

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost