Author Topic: Attribute alignment issue using ObjectDBX  (Read 10901 times)

0 Members and 1 Guest are viewing this topic.

SteveK

  • Guest
Attribute alignment issue using ObjectDBX
« on: October 13, 2009, 12:56:11 AM »
Hi,

I've been using an attribute editor that works on multiple drawings (by Lee Mac - I got it here http://www.cadtutor.net/forum/showpost.php?p=248502&postcount=10) and a problem occurs where when an attribute is modified it aligns to left (even if it is currently right or center aligned).

I would just re-align the attribute however the attribute's alignment property remains what it was previously.

Firstly, does anyone modify attributes over multiple drawings? and secondly, if so, have you come across this problem that I have and can you think of a solution?

Thankyou  :-)

Steve

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Attribute alignment issue using ObjectDBX
« Reply #1 on: October 13, 2009, 01:22:14 AM »
This is one of the main reason I went to C#.  It can't really be done with other languages, so if you want to use lisp, then you are either stuck opening the drawings in the editor, or living with the look of misaligned attribute/text entities.  Meaning that one you open the drawing, and move the items in question, they realign themselves, at least that is what I remember happening.
Tim

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

Please think about donating if this post helped you.

Joe Burke

  • Guest
Re: Attribute alignment issue using ObjectDBX
« Reply #2 on: October 13, 2009, 05:48:29 AM »
In addition to what Tim said, it is a known problem and likely a bug. Maybe fixed in some future version?

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Attribute alignment issue using ObjectDBX
« Reply #3 on: October 13, 2009, 12:38:19 PM »
i don't think it is a bug
one have to update not only text's TextString but also recalculate and update text's InsertionPoint

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Attribute alignment issue using ObjectDBX
« Reply #4 on: October 13, 2009, 02:03:12 PM »
In addition to what Tim said, it is a known problem and likely a bug. Maybe fixed in some future version?

Given the current "static" nature of LISP and VBA being on the way to the funeral home, I kind of doubt it.  Unless some clever person comes up with an easy .NET replacement for LISP.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

SteveK

  • Guest
Re: Attribute alignment issue using ObjectDBX
« Reply #5 on: October 13, 2009, 05:07:09 PM »
Thanks for all your comments; well I guess that's that. :-)   Must be time to look up C#/++.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Attribute alignment issue using ObjectDBX
« Reply #6 on: October 14, 2009, 08:12:06 AM »
i don't think it is a bug
one have to update not only text's TextString but also recalculate and update text's InsertionPoint

Yes, I suppose this could be done... but time is pretty short at the moment...  :|

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Attribute alignment issue using ObjectDBX
« Reply #7 on: October 14, 2009, 11:07:13 AM »
i don't think it is a bug
one have to update not only text's TextString but also recalculate and update text's InsertionPoint

Yes, I suppose this could be done... but time is pretty short at the moment...  :|

I think I tried this, and it still didn't work they way you would think, so I do think it is a bug, as it happens with the other languages also.  To bypass this issue you have to set the database current, in C# at least, or it will still show the text in the wrong location.
Tim

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

Please think about donating if this post helped you.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Attribute alignment issue using ObjectDBX
« Reply #8 on: October 14, 2009, 01:45:50 PM »
Tim, i did some testing, and i'm 99% sure that (vlax-put txtObj 'TextString ...) does the trick
if txtObj (centered or right-aligned) is in the current drawing the printouts will be different
Code: [Select]
(print (vlax-get txtObj 'InsertionPoint))
(vlax-put txtObj 'TextString (strcat "test" (vlax-get txtObj 'TextString)))
(print (vlax-get txtObj 'InsertionPoint))
acad updates 'InsertionPoint automatically

if txtObj descends from a dbx-ed drawing the printouts will be the same
so we must update 'InsertionPoint ourselves

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Attribute alignment issue using ObjectDBX
« Reply #9 on: October 14, 2009, 02:30:02 PM »
Vovka,

If you move the object ( after you edit it dbx style, and then open the drawing in the editor ), then the alignment will be correct.  I'm pretty sure I tried what you are talking about before, and it didn't work for me, and I don't know why.  If you think it will work, then maybe you can code it up and share.  I think a lot of people would be greatful if you can really edit text/attributes with ObjectDBX, and have the objects not move.  I have been wrong before, so maybe I didn't do it correctly in my testing.

Edit:  I think the issue is that you can change the InsertionPoint property of a text object that isn't left justified all you want, and nothing will happen.  I think that was the issue, that even if you change the insertion point, it doesn't do anything.  Here is what I'm talking about:
Quote
Command: (vlax-get ob2 'insertionpoint)
(25.8225 26.7905 0.0)

Command: (vlax-put ob2 'insertionpoint '(0. 0. 0.))
nil

Command: (vlax-get ob2 'insertionpoint)
(25.8225 26.7905 0.0)

Command: (vlax-get ob2 'alignment)
4
« Last Edit: October 14, 2009, 02:33:11 PM by T.Willey »
Tim

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

Please think about donating if this post helped you.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Attribute alignment issue using ObjectDBX
« Reply #10 on: October 14, 2009, 05:49:50 PM »
Tim,
i work in autodesk map 2005 and i don't have problems with updating 'InsertionPoint via dbx

but the bad thing is that it is not so easy to calculate 'InsertionPoint mathematically
this is what i have so far
Code: [Select]
(defun CalcInsPoint (EntName NewStr / EntProps HA)
;;;does not work with 'Align' and 'Fit' justifications
  (setq EntProps (entget EntName)
HA (cdr (assoc 72 EntProps))
  )
  (polar (cdr (assoc 10 EntProps))
(cdr (assoc 50 EntProps))
(* (apply '+
   (mapcar (function (lambda (e1 e2) (- (car e1) (car e2))))
   (textbox EntProps)
   (textbox (subst (cons 1 NewStr) (assoc 1 EntProps) EntProps)
   )
   )
    )
    (cond ((= HA 0) 0.0)
  ((or (= HA 1) (= HA 4)) 0.5)
  ((= HA 2) 1.0)
    )
)
  )
)
i tested it within Lee's code from the first post
put
Code: [Select]
(progn (vla-put-InsertionPoint
Att
(vlax-3d-point (CalcInsPoint (vlax-vla-object->ename Att) (cdr Tag)))
       )
       (vla-put-TextString Att (cdr Tag))
)
instead of
Code: [Select]
(vla-put-TextString Att (cdr Tag))
« Last Edit: October 15, 2009, 12:06:26 PM by VovKa »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Attribute alignment issue using ObjectDBX
« Reply #11 on: October 15, 2009, 11:09:09 AM »
Vovka,

  Maybe the problem is most of my text that isn't Left justified is Middle justified, and you code said it's for baseline justification only, so it wouldn't work on my text, and if it doesn't work on all text objects, then I still think it doesn't work.  I'll see about testing it today if I have time.
Tim

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

Please think about donating if this post helped you.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Attribute alignment issue using ObjectDBX
« Reply #12 on: October 15, 2009, 12:14:34 PM »
Tim, i've updated my function in the previous post.
i've eliminated some of the limitation
but still, i can not calculate the 'InsertionPoint to a high degree of accuracy
anyway, it looks OK on the screen

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Attribute alignment issue using ObjectDBX
« Reply #13 on: October 15, 2009, 01:19:35 PM »
Nicely done Vovka!  I have been proven wrong, and don't mind one bit.   :-D

Edit:  Spoke too soon.  This works if all the text styles are in both drawings, and the properties are the same.  Pic attached to illustrate.  I only had two of the styles in the drawing that I called the routine from, and they are the top two on the right side, and the bottom of the two has different style properties.  You can see that they are not lined up correctly.  The problem is the textbox call.

Edit2:  Maybe if you create the text within the file with all the same props as the original one, but with the next text string, and get the insertion point relative to the text alignment point, and use that to get the new insertion point.  Just an idea.
« Last Edit: October 15, 2009, 01:32:37 PM by T.Willey »
Tim

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

Please think about donating if this post helped you.

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: Attribute alignment issue using ObjectDBX
« Reply #14 on: October 15, 2009, 02:28:08 PM »
Tim, it's good that you've finally believed the it can be done :)

as to 'Edit2' - it was the first thing i thought of when i tried to find 'InsertionPoint. but i didn't like the idea because i had to copy/update all textstyles from dbx-ed document into current drawing. and now, i suspect that it might be the only solution.