Author Topic: Correcting entities mirrored by dxf code 210  (Read 5900 times)

0 Members and 1 Guest are viewing this topic.

hmspe

  • Bull Frog
  • Posts: 362
Correcting entities mirrored by dxf code 210
« on: January 22, 2010, 12:52:52 PM »
I've read what's at this site and I'm baffled.  Bricscad apparently uses a different method to mirror than Autocad does and I'm trying to fine a way to "normalize" the mirrored entities.  To get entity data I inserted an entity at (-1.0,5.0.0.0) then mirror the object around the line from 0,0 to 0,5.

In Autocad I see entity codes

((-1 . <Entity name: 7ffffb05a80>) (0 . "INSERT") (330 . <Entity name:7ffffb039f0>) (5 . "198") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "power") (100 . "AcDbBlockReference") (2 . "E_RECDUPLEX") (10 -1.0 5.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0)) <---- original entity

((-1 . <Entity name: 7ffffb05a90>) (0 . "INSERT") (330 . <Entity name:7ffffb039f0>) (5 . "199") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "power") (100 . "AcDbBlockReference") (2 . "E_RECDUPLEX") (10 1.0 5.0 0.0) (41
. -1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0)) <---- mirrored entity

In Bricscad I see:

((-1 . <Entity name: 056c51f8>) (0 . "INSERT") (5 . "94") (330 . <Entity name: 02ef7bb8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "power") (62 . 256) (48 . 1.0) (284 . 0) (100 . "AcDbBlockReference") (2 . "E_RECDUPLEX") (10 -1.0 5.0 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (210 0.0 0.0 1.0)) <---- original object

((-1 . <Entity name: 056c4bb8>) (0 . "INSERT") (5 . "95") (330 . <Entity name: 02ef7bb8>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "power") (62 . 256) (48 . 1.0) (284 . 0) (100 . "AcDbBlockReference") (2 . "E_RECDUPLEX") (10 -1.0 5.0 0.0) (41 . 1.0) (42 . 1.0) (43 . -1.0) (50 . 0.0) (210 -0.0 -0.0 -1.0)) <---- mirrored object


In Autocad I can look at dxf 41 to see if an entity is mirrored.  Obviously not in Bricscad.  What I'd like to do is trap entities with a dxf 210 code that's not 0.0 0.0 1.0 and convert them to "normalized" 2D entities with (210 . 0.0 0.0 1.0), but I'm not understanding how to determine the new value for the insertion point.  Everything I've tried so far moves the entity.  Everything my office does is 2D so I'm not very familiar with 3D coding, trans functions, and such.  Any help would be appreciated.
"Science is the belief in the ignorance of experts." - Richard Feynman

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Correcting entities mirrored by dxf code 210
« Reply #1 on: January 22, 2010, 01:07:44 PM »
Just to clarify, bear in mind that 41 (& 42,43) are purely the scale factor of the INSERT, and not a "Mirror flag"

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Correcting entities mirrored by dxf code 210
« Reply #2 on: January 22, 2010, 01:46:11 PM »
That how an insert is mirrored in ACAD, just minus the X-Scale.
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.

hmspe

  • Bull Frog
  • Posts: 362
Re: Correcting entities mirrored by dxf code 210
« Reply #3 on: January 22, 2010, 07:04:46 PM »
Lee Mac,
True, but based on posts I've read here at The Swamp if dxf 41 is negative the entity is mirrored.  It may not be totally correct but it seems to work for 2D drawings.

CAB,
It may be that the process is the same, but in Autocad the insertion points (dxf 10 values) reported for the entities are the insertion points for the individual entities, while in Bricscad the insertion points reported for both entities are the insertion point for the original entity  [(-1.0 5.0 0.0)], even though the entities render at (-1.0 5.0 0.0) and (1.0 5.0 0.0).  I've attached a test file created in Bricscad.  If you list the two inserts in Autocad you'll see that Autocad reports that they have the same insertion point. 

In looking at the dxf codes for the original insert and the mirrored insert the only things related to location that change in Bricscad are codes 43 and 210.  Since Autocad renders this correctly there must be enough information in those codes for Autocad to determine that the insert is mirrored and how/where to render it correctly.  The insertion Osnap in Autocad finds the correct point on each symbol, which surprises me since the dxf 10 code for the mirrored insert is not the insertion Osnap point.  What's failing for me is a routine you helped with a while back that adds a circuit number for the receptacles.  That routing lets the user pick a selection set of receptacles, prompts for on-screen entry of the circuit number at one of the receptacles, then adds the same text at all the other receptacles.  The routine uses the dxf 10 code and the dxf 50 code for each entity to determine where the text insertion point should be and the justification of the text on a per-entity basis.  The lisp works fine in Autocad but in Bricscad the text gets inserted in unexpected places because the dxf 10 code for mirrored entities does not correspond to the insertion point.  Using Autocad 2010 and the latest Bricscad here.

The people at Bricsys seem to be very good at fixing problems when they are reported and they want lisp routines to work the same in Bricscad as in Autocad.  I've reported this and hope that they will schedule it to be fixed.  In the mean time I'm trying to find a work-around.  I'm thinking along the lines of of a lisp I can append to the Bricscad mirror command which will "correct" mirrored inserts so the dxf 10 and 50 codes correspond to actual insertion point and actual rotation.  So far no joy in figuring this out.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Correcting entities mirrored by dxf code 210
« Reply #4 on: January 22, 2010, 07:33:45 PM »
If you want the correct insertion point per object, then you can use code like:

Code: [Select]
(
    (lambda (data)
        (trans
            (cdr (assoc 10 data))
            (cdr (assoc 210 data))
            1
        )
    )
    (entget (car (entsel)))
)

This code will take the insertion point ( code 10 ) and translate it ( trans ) by the plane/normal face the block is inserted on ( code 210 ) to the current coordinate system ( why the 1 is there ).  Hope that makes sense.
Tim

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

Please think about donating if this post helped you.

hmspe

  • Bull Frog
  • Posts: 362
Re: Correcting entities mirrored by dxf code 210
« Reply #5 on: January 22, 2010, 11:41:42 PM »
Tim, Lee Mac, and CAB, thanks for the responses and for getting me going in the right direction.  This seems to normalize the entities for 2D drawings:

Code: [Select]
(defun c:show ( / selection entity new_point new_rotation)
  (while (null (setq selection (entsel "\nPick an object to show: "))))
  (setq selection (car selection)
        entity (entget selection)
  )
  (setq new_point (trans
                    (cdr (assoc 10 entity))
                    (cdr (assoc 210 entity))
                    1
                  )
  )
  (setq new_rotation (- (* 3.0 pi) (cdr (assoc 50 entity))))
  (while (> new_rotation (* 2.0 pi))
    (setq new_rotation (- new_rotation (* 2.0 pi)))
  )
  (if (= (car (cddr (cdr (assoc 210 entity)))) -1.0)
    (progn
      (setq entity (subst (cons 10 new_point) (assoc 10 entity) entity))
      (setq entity (subst (cons 50 new_rotation) (assoc 50 entity) entity))
      (setq entity (subst (cons 43 1.0) (assoc 43 entity) entity))
      (setq entity (subst (cons 210 '(0.0 0.0 1.0)) (assoc 210 entity) entity))
      (entmod entity)
    )
  )
  (princ)
)
"Science is the belief in the ignorance of experts." - Richard Feynman

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Correcting entities mirrored by dxf code 210
« Reply #6 on: January 23, 2010, 06:34:37 AM »
You're welcome  :-)

A minor point, but this:

Code: [Select]
(while (> new_rotation (* 2.0 pi))
  (setq new_rotation (- new_rotation (* 2.0 pi))))

Could be replaced with:

Code: [Select]
(setq new_rotation (rem new_rotation (* 2. pi)))

yaque

  • Guest
Re: Correcting entities mirrored by dxf code 210
« Reply #7 on: January 24, 2010, 10:33:57 AM »
I don't know if your routine can work in Bricscad.
I looked at a file in Bricscad v10 that was created in Autocad R14

A typical mirrored block has dxf values of
(10 2927.63 11135.6 0.0)
(41 . -1.0)
(42 . 1.0)
(43 . 1.0)
(50 . 4.71239)
(210 0.0 0.0 1.0)

when copied or even moved
it changes to
(10 -2927.63 11135.6 0.0)
(41 . 1.0)
(42 . 1.0)
(43 . -1.0)
(50 . 1.5708)
(210 -0.0 -0.0 -1.0)

Bricscad apparently insists on it's own system.
(I don't really want to open the file back in Autocad to see what happens,
because Autocad hijacks the .dwg file association)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Correcting entities mirrored by dxf code 210
« Reply #8 on: January 24, 2010, 11:04:44 AM »
Wow, that's strange.
I guess the question is "What is wrong with the Bricscad method?


Welcome to the Swamp. 8-)
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.

yaque

  • Guest
Re: Correcting entities mirrored by dxf code 210
« Reply #9 on: January 24, 2010, 01:04:22 PM »
Thanks,
I've been lurking here for a month or so.

I'm trying out Bricscad with the intention of migrating our office to it.
We've been working on Autocad R14 since the last ice age,
and i rather think that it's time to move on. :)

I've been gradually adapting about 1.7mb worth of lisps to Bcad over the last few months.
It's been easier than I thought, but with a number of idiosyncrasies.

This site has already been a great help!
For example, this thread has brought this particular issue into focus for me,
and probably explains half a dozen strange problems with some of my lisps.
I'll cross-post this issue over on the Bricscad forum.


CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Correcting entities mirrored by dxf code 210
« Reply #10 on: January 24, 2010, 02:22:44 PM »
Is there a list of these idiosyncrasies anywhere?
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.

hmspe

  • Bull Frog
  • Posts: 362
Re: Correcting entities mirrored by dxf code 210
« Reply #11 on: January 24, 2010, 04:54:52 PM »
CAB,

I don't know of a list.  What I've found is that well over 98% of my lisp routines work in Bricscad V10 just like they do in Autocad, with no changes required.  The issues I've seen look to me like unintended consequences that result from writing a program to a specification -- there are always "features" that are not in the specification.  The things I've had problems with are:

1.  GRREAD returns codes for the arrow keys that are the same codes as for %, &, (, and '.  This is on the their schedule to fix.  This is more of an inconvenience than a show-stopper.
2.  Reading from a binary file in Bricscad stops when a 00 byte is encountered rather than reading to the actual end of the file.  This is fixed and will be in a future update.  This could be critical for some but for me is just an inconvenience -- I had looked at reading the line feed height from SHX files for a routine that restacks TEXT entities.  Since we use about 6 fonts for 99% of our work I hard-coded the correct values in the lisp routine.
3.  When the TEXT (or DTEXT) command is called from lisp it runs like the Autocad 2000 era single line TEXT command rather than as the multi-line DTEXTconmmand.  I've worked around this by changing my routine so it creates and runs a script.  See the discussion in the "Pause for Text command run from lisp" thread in the Bricscad forum.
4.  This issue with mirroring.  I have posted a bug report but have not yet heard back.  For now I'll run the following if I need to clean up a file:

Code: [Select]
(defun c:um ( / selset index entity new_point new_rotation)
  (if (setq selset (ssget "_X" '((-4 . "*,*,=")(210 0.0 0.0 -1.0))))
    (progn
      (setq index 0)
      (while (< index (sslength selset))
        (setq entity (entget (ssname selset index)))
        (setq new_point (trans
                          (cdr (assoc 10 entity))
                          (cdr (assoc 210 entity))
                          1
                        )
        )
        (setq new_rotation (- (* 3.0 pi) (cdr (assoc 50 entity))))
        (setq new_rotation (rem new_rotation (* 2. pi)))
        (setq entity (subst (cons 10 new_point) (assoc 10 entity) entity))
        (setq entity (subst (cons 50 new_rotation) (assoc 50 entity) entity))
        (setq entity (subst (cons 43 1.0) (assoc 43 entity) entity))
        (setq entity (subst (cons 210 '(0.0 0.0 1.0)) (assoc 210 entity) entity))
        (entmod entity)
        (setq index (1+ index))
      )
    )
  )
  (princ)
)

The fixes for me have been no worse than what I've had to do for some new releases on Auticad.  My staff is using Bricscad successfully and with essentially no loss of productivity.  I especially like that the programmers respond to bug reports and are active in their forums, and that they actually release updates regularly.

Martin
"Science is the belief in the ignorance of experts." - Richard Feynman

yaque

  • Guest
Re: Correcting entities mirrored by dxf code 210
« Reply #12 on: January 25, 2010, 03:06:11 AM »
I agree.
I'm also not having too much trouble, and the team is great and very responsive!

For example, one small bug I found was that (distof ".") returned 0.0 in Bricscad and nil in Autocad.
And I asked that they make it possible to copy Read-Only values in the property bar.
(specifically Block names of inserts, so I can create a new block based on an existing block name without having to type it out)
Obscure stuff like that.
They fixed them in the next update.

A mirrored Minsert entity with negative column or row values is drawn the reverse of what it should be.
They gave me a lisp to fix them in the meantime until they fix the bug.

Of course you'll find that command prompts are occasionally different.
(For example, "Select" does not have a "single" option which breaks a couple of things)

Bricscad is also sometimes less tolerant of improper formatting of input, so it made me fix a few of my own bugs.