Linetype Generation Disabled to Enabled in LISP

Linetype Generation Disabled to Enabled in LISP

Anonymous
Not applicable
1,012 Views
4 Replies
Message 1 of 5

Linetype Generation Disabled to Enabled in LISP

Anonymous
Not applicable

Hello all,

 

I currently have a LISP to weed duplicate alignments on polylines.

This LISP works perfectly except once the routine has run the polylines linetype generation becomes disabled!

Obviously this creates another step that needs to be taken and I wish eliminate it.

 

So the question is how can this be achieved?

Is there something in this LISP I am missing or does something need to added?

 

Attached is the LISP for refference.

 

Thanks in advance.

0 Likes
1,013 Views
4 Replies
Replies (4)
Message 2 of 5

Kent1Cooper
Consultant
Consultant

I don't see anything in the code that should be changing that, which makes me wonder [the stupid question]: do the Polylines have linetype generation enabled to start with?

 

For an individual Polyline, whether linetype generation is enabled is stored by whether the 128 bit is contained in the (assoc 70) entry in entity data, or whether the Linetypegeneration VLA Property is 0 [disabled] or (oddly) -1 [enabled].  You can certainly force it to be enabled for every Polyline the routine processes, via either (subst)/(entmod) or (vla-put-linetypegeneration).  [EDIT -- see one way to do it below]

 

But I notice something else in the code that's overly complicated.  In the 'nel' entity-data list, there are a lot of entries [most of them] in this form:

 

  (cons 70 (cdr (assoc 70 oel)))

 

which takes the 70-code entry from the "old" entity data list, removes the 70 from it, and then puts it back together with another 70 for the entry in the "new" list.  That's redundant -- each line that's built that way can just take that entry from the "old" list just as it is, for instance in the above example, just:

 

  (assoc 70 oel)

 

EDIT:  Since the code does not otherwise involve converting things to VLA objects, it's probably easier to force linetype generation on by entity-data-list means.  I would do it this way, in that 'nel' list, replacing the above 70-code line with this, to make sure the 128 bit is included:

  (cons 70 (logior 128 (cdr (assoc 70 oel))))

Kent Cooper, AIA
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks kentcooper for the reply but ufortunatley this does not work.

It regenerates the the linetype fine but prevents it from weeding the multiple alignments the the script is designed to do!?

I'm not really sure why, can you see the problem?

 

Also is it possible to modify the script to set the polyline to 'by layer'?

 

Thanks for your with this.

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

It regenerates the the linetype fine but prevents it from weeding the multiple alignments the the script is designed to do!?

.... 

Also is it possible to modify the script to set the polyline to 'by layer'?

....


Since the terminology is unfamiliar, it would help me if you can post an image or sample drawing showing what it means to "weed an alignment" (before and after, pointing out where the differences are).  If it means to eliminate extra vertices in collinear or nearly collinear series of line segments, there are other routines out there to do that, such as this [which uses the term "weed" -- that's what made me think of it -- but maybe not in the way you mean].

 

Set what about the Polyline to 'by layer' -- color? linetype? both? something else?

 

[And by the way, it's not a Script -- that has a specific and different meaning in AutoCAD.]

Kent Cooper, AIA
0 Likes
Message 5 of 5

dbroad
Mentor
Mentor

When you rebuild an existing polyline using DXF techniques, you must rebuild it with a specific sequence of DXF codes.  Your sequence does not match the required sequence.  Try:

(setq nel (list (cons -1 (cdr (assoc -1 oel)))
		    (cons 0 (cdr (assoc 0 oel)))
		    (cons 330 (cdr (assoc 330 oel)))
		    (cons 5 (cdr (assoc 5 oel)))
		    (cons 100 (cdr (assoc 100 oel)))
		    (cons 67 (cdr (assoc 67 oel)))
		    (cons 410 (cdr (assoc 410 oel)))
		    (cons 8 (cdr (assoc 8 oel)))
		    '(100 . "AcDbPolyline")
		    (cons 90 (/ (length vlist4) 4))
		    (cons 70 (cdr (assoc 70 oel)))
		    (cons 43 (cdr (assoc 43 oel)))
		    (cons 38 (cdr (assoc 38 oel)))
		    (cons 39 (cdr (assoc 39 oel)))
		    
	      ) ;_ end of list

Although, since I agree with Kent, it should be.

(setq nel (list (assoc -1 oel)
		    (assoc 0 oel)
		    (assoc 330 oel)
		    (assoc 5 oel)
		    (cdr (assoc 100 oel)
		    (assoc 67 oel)
		    (assoc 410 oel)
		    (assoc 8 oel)
		    '(100 . "AcDbPolyline")
		    (cons 90 (/ (length vlist4) 4))
		    (assoc 70 oel)
		    (assoc 43 oel)
		    (assoc 38 oel)
		    (assoc 39 oel)
		    
	      ) ;_ end of list

But there are also many other places that the code did not follow LISP coding practices.  Looks like a Fortran programmer looked briefly through a function list and cobbled together a program.  Nicely documented though.

Architect, Registered NC, VA, SC, & GA.
0 Likes