TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: S.Langhammer 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:
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:
(defun getLinData
( ent
/ entAPt entEPt
) ;;;Linien )
;;; 0 . Entitätentyp
;;; 1 . Layername
;;; 2;3;4 . Startpunkt
;;; 5;6;7 . Endpunkt
;;; 8 . Länge
(princ) ;;; max list index 8 ) ;;; ende getLinData
When I print out the entget of this to the command console, everything looks fine, but after the export: scrambled eggs...
-
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.
-
You can set the WCS with
(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).
-
Here you go, provided by Lee Mac.
This should help.
http://lee-mac.com/matrixtransformationfunctions.html
-
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?
-
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:
(setq org (cdr (assoc 10 (entget (tblobjname "block" "wall_100")))))
(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:
(setq translatedPoint (mapcar '- originalPoint org))
-
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!
-
might be useful:
https://groups.google.com/d/msg/autodesk.autocad.customization/3TM_C7Pn_gM/xccswdyOi7AJ (https://groups.google.com/d/msg/autodesk.autocad.customization/3TM_C7Pn_gM/xccswdyOi7AJ)
;;; 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
-
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
-
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.