Author Topic: access 2nd DXF in list ...  (Read 2181 times)

0 Members and 1 Guest are viewing this topic.

Hangman

  • Swamp Rat
  • Posts: 566
access 2nd DXF in list ...
« on: September 29, 2010, 12:12:57 PM »
Morning everyone,

How would I access the 2nd DXF point list in a list ?
Here's what I have:
Code: [Select]
(setq a (car (entsel)))
(setq b (entget a))
Quote
((-1 . <Entity name: 7e561748>) (0 . "LWPOLYLINE") (330 . <Entity name:
7edf1ee8>) (5 . "11561") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
"ELC Text") (62 . 3) (100 . "AcDbPolyline") (90 . 2) (70 . 0) (43 . 0.0) (38 .
-101.616) (39 . 0.0) (10 186.783 18.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 .
0) (10 186.783 42.0) (40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 -1.0
0.0))
And I want to access the 2nd point list of 10 (in Green).

I have accessed already the first (in Purple) with this:
Code: [Select]
(setq c1 (assoc 10 b))But how do I access the 2nd ?   And, I guess I had better ask this question too, how would I 'entmod' the 2nd ?
I would assume it has to be different than this:
Code: [Select]
(entmod (subst (cons 10 NewPointList)(assoc 10 b) b))as this would simply modify the 1st point list of 10.

Thank you for your expertise and opinions as always.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

T.Willey

  • Needs a day job
  • Posts: 5251
Re: access 2nd DXF in list ...
« Reply #1 on: September 29, 2010, 12:32:39 PM »
How do you know you want to change the second code 10?  Once you know that, then you can do what you want to do, because you will have to know in order to do it.  You can use ' foreach ' only changing the one you want, or you can use ' (assoc 10 (cdr (member (assoc 10 entdata) entdata))) '.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

ronjonp

  • Needs a day job
  • Posts: 7535
Re: access 2nd DXF in list ...
« Reply #2 on: September 29, 2010, 12:36:35 PM »
or something like this:


Code: [Select]
(defun getati (ent i / l)
;;1 is first pt 2 second ... so on
  (if (setq l (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget ent)))
    (nth (1- i) l)
  )
)
(getati (car (entsel)) 2)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Hangman

  • Swamp Rat
  • Posts: 566
Re: access 2nd DXF in list ...
« Reply #3 on: September 29, 2010, 12:50:23 PM »
How do you know you want to change the second code 10?  Once you know that, then you can do what you want to do, because you will have to know in order to do it.  You can use ' foreach ' only changing the one you want, or you can use ' (assoc 10 (cdr (member (assoc 10 entdata) entdata))) '.

Tim, good question.  I have some drawings that have some 3D piping and such that was done in Microstation.  Once converted to DWG, they are basically dumb drawings but I have plines at all levels of the spectrum.  I need to bring these plines down to the ground from some positive elevation, or up from some negative elevation.  Listing the plines, they have their DXF 210 list as (0.0 1.0 0.0) and (1.0 0.0 0.0) so I know they are either vertical or drawn at some angle other than from the TOP.  Going through all the DXF 10 listing, I have realized that in each one, the second point is designated to the elevation from the TOP or plan view.  By changing this second point, you can bring the vertex to whatever elevation you desire.
I have not yet played with 3Dplines, nor have I experimented very much with plines of several vertex's, so your opinions here would be most welcome as well.

From looking at the pline from the FRONT view, I was able to adjust a vertical pline's 1st vertex from it's elevation to zero, but I don't know how to access the second or third vertex's to do the same.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Hangman

  • Swamp Rat
  • Posts: 566
Re: access 2nd DXF in list ...
« Reply #4 on: September 29, 2010, 12:56:15 PM »
The more I think about it though, the more difficult I think this is going to be.  I need to first, find the elevation of the pline at it's lowest point to zero, then subtract that distance from each vertex.  Or if it's on the negative, add the distance to each vertex.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: access 2nd DXF in list ...
« Reply #5 on: September 29, 2010, 01:42:29 PM »
Are you trying to Flatten the DWG?
http://www.theswamp.org/index.php?topic=18153.0
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Hangman

  • Swamp Rat
  • Posts: 566
Re: access 2nd DXF in list ...
« Reply #6 on: September 29, 2010, 02:58:34 PM »
Are you trying to Flatten the DWG?

Yes I am.  I have the SuperFlatten and I have to admit, it is an awesome program, I love it for the most part.  But I have run into a few situations where SuperFlatten failed to perform as was written and caused more work than solutions.
I would have let Joe know about them, but I can't post any drawing(s) to allow him the experience I am getting from it, so it's almost a mute point.  When I get more time than money allows, I will clean the drawings up to the point I can upload and see if I can't assist in fixing Superflatten so it'll be even better.
In the mean time though, I am learning a lot by trying to code it myself.  It's taking me a very long time, but I'm in no hurry.  I'm using Superflatten as a template with the parts I understand easily enough.  With the not so easy to understand code, I slowly work it out and post a lot here at the swamp.
Hangman  8)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Drafting Board, Mechanical Arm, KOH-I-NOOR 0.7mm
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Harrie

  • Guest
Re: access 2nd DXF in list ...
« Reply #7 on: October 14, 2010, 04:47:56 AM »
See http://forums.augi.com/showthread.php?t=124979 (Nth item in DXF list) with HofCAD's ChNthDxf subroutine
(Change Nth Dxf code) for editing LWpolylines, mlines, leaders, tables and splines.
Examples on http://forums.augi.com/showthread.php?t=124979&page=3
« Last Edit: October 15, 2010, 05:16:01 AM by Harrie »