Author Topic: Reading Out entity data - displaced informations within block  (Read 3067 times)

0 Members and 1 Guest are viewing this topic.

S.Langhammer

  • Guest
Reading Out entity data - displaced informations within block
« on: October 21, 2013, 10:30:11 AM »
I wasn't able to work on the Lisp-project for quite a while now. Vocational college and more urgent tasks kept me occupied.

Those, who I've annoyed here for a while know my issue: I'm using LISP and BricsCAD to read the drawing information from a .dwg file and write it into a .txt.

After some testing collegues of mine noticed, basicly everything within blocks is displaced. That came out so late, because they don't necessarily have to look directly into the .txt. The Delphi-side of the Interface shows grafiks in open gl.

Basicly every line (and propably every other entity as well) is displaced by a distance, I assume to come from a block. I'm actually puzzled.

Yet I do suspect a code construct I use to be the cause of this:

Code - Auto/Visual Lisp: [Select]
  1.         (vla-put-activeucs activeDocument
  2.                 (vla-add
  3.                         (vla-get-usercoordinatesystems activeDocument)
  4.                         (vlax-3d-point '(0 0 0)) ;origin
  5.                         (vlax-3d-point '(1 0 0)) ;x-axis
  6.                         (vlax-3d-point '(0 1 0)) ;y-axis
  7.                         "World"
  8.                 )
  9.         )
  10.  

I actually use it to ensure a WCS-Like UCS is current. I would rather use the WCS itself but I  don't know how to set that active.

Now when I read a line for example I do it like this:

Code - Auto/Visual Lisp: [Select]
  1. (defun getLinData( ent / entAPt entEPt) ;;;Linien
  2.         (setq entAPt    (cdr(assoc 10 ent))     ;;; Startpunkt
  3.                   entEPt        (cdr(assoc 11 ent))     ;;; Endpunkt
  4.         )
  5.         (fileWrite(strcat "LINE,"(cdr(assoc 8 ent))","(rtos(car entAPt)2 4)","(rtos(cadr entAPt)2 4)","(rtos(caddr entAPt)2 4)","(rtos(car entEPt)2 4)","(rtos(cadr entEPt)2 4)","(rtos(caddr entEPt)2 4)","(rtos(distance entAPt entEPt)2 4)))                                                                                                                                                                                                                                 ;;; Ausgabeliste an die Datei anhängen
  6.         ;;; 0 . Entitätentyp
  7.         ;;; 1 . Layername
  8.         ;;; 2;3;4 . Startpunkt
  9.         ;;; 5;6;7 . Endpunkt
  10.         ;;; 8 . Länge
  11.         (princ) ;;; max list index 8
  12. )       ;;; ende getLinData
  13.  

When I print out the entget of this to the command console, everything looks fine, but after the export: scrambled eggs...

Bhull1985

  • Guest
Re: Reading Out entity data - displaced informations within block
« Reply #1 on: October 21, 2013, 11:50:22 AM »
Can you post example .dwg and .txt?
Are you referring to block attribute values that are misplaced?
Pretty sure an expert will be along to help you soon enough as long as they have the required information to do so.

Woabow

  • Newt
  • Posts: 56
Re: Reading Out entity data - displaced informations within block
« Reply #2 on: October 21, 2013, 03:03:32 PM »
You can set the WCS with
Code: [Select]
(command "ucs" "w")
But if you are trying to export a line within a block you will export the position as seen from inside the block, not the position in the drawing. You have to transform the position with the block matrix and this has to be recursive (because the block can be a nested block).
« Last Edit: October 21, 2013, 03:15:06 PM by Woabow »

Bhull1985

  • Guest
Re: Reading Out entity data - displaced informations within block
« Reply #3 on: October 21, 2013, 05:25:26 PM »
Here you go, provided by Lee Mac.
This should help.

http://lee-mac.com/matrixtransformationfunctions.html

S.Langhammer

  • Guest
Re: Reading Out entity data - displaced informations within block
« Reply #4 on: October 28, 2013, 08:51:05 AM »
Ok I THOUGHT Woabow's tip would help. Finally I managed to test the lisp again. FAIL.

The first test looked perfect. But don't ask me why, the second test (examples attached) looks like this.

I'm officially clueless! Does anyone have an idea, what I might be doing wrong?

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Reading Out entity data - displaced informations within block
« Reply #5 on: October 29, 2013, 05:59:38 AM »
Steven, the drawing you are using for testing is somewhat special. Some block definitions have an origin (or base point) that is not (0.0 0.0 0.0). Perhaps these blocks were created using some special software.

For a block named "wall_100" you can use one of the following bits of code to get the origin:
Code: [Select]
(setq org (cdr (assoc 10 (entget (tblobjname "block" "wall_100")))))
Code: [Select]
(setq org
  (vlax-get
    (vla-item
      (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object)))
      "wall_100"
    )
    'origin
  )
)

You have to use the origin to translate all point values inside the block definition:
Code: [Select]
(setq translatedPoint (mapcar '- originalPoint org))

S.Langhammer

  • Guest
Re: Reading Out entity data - displaced informations within block
« Reply #6 on: October 29, 2013, 07:00:45 AM »
I can't write down, what I think right now, cuz children could read it.
I never thought of that possibility.
Thanks roy, thanks a lot really. It could have saved me a lot of frustration, if I had an idea of that earlier!

Now I'll have a lot of work fixing this on both delphi and lisp side.

Again thanks!

danallen

  • Guest
Re: Reading Out entity data - displaced informations within block
« Reply #7 on: October 29, 2013, 09:11:53 AM »
might be useful:

https://groups.google.com/d/msg/autodesk.autocad.customization/3TM_C7Pn_gM/xccswdyOi7AJ

Code: [Select]
;;; From: "Joe Burke" <jobu...@hawaii.rr.com>
;;; Newsgroups: autodesk.autocad.customization
;;; Subject: Re: how to change the insertpoint of a block,and keep the insert objects's  place
;;; Date: Fri, 8 Oct 2004 03:00:51 -1000

;;; JB version 3  10/7/2004
;;; function: move a block's insertion point and fix all existing references
;;; tested in a UCS with mirrored and non-uniformly scaled blocks

S.Langhammer

  • Guest
Re: Reading Out entity data - displaced informations within block
« Reply #8 on: October 30, 2013, 06:33:50 AM »
You have a point there danallen. Now I gotta find a way to hand over only the entity name (dxf group code -2) to the function properly.
I have to edit it to work automatized. best BEFORE i read out blocks, consiering, that they can contain inserts as well

S.Langhammer

  • Guest
Re: Reading Out entity data - displaced informations within block
« Reply #9 on: October 30, 2013, 06:37:32 AM »
Gotta correct myself, i just noticed, it only works with inserts, that are available though selection. As I recall, you can't do that with Inserts within Blocks.