ObjectARX

Reply
Distinguished Mentor
Moshe-A
Posts: 739
Registered: ‎09-14-2003
Message 1 of 10 (174 Views)
Accepted Solution

attributes are placed in 0,0 position

174 Views, 9 Replies
11-07-2012 10:28 PM

Hi Guys,

 

In my application i have three block symbols contains some attributes. the current task i'm working on

is converting an old version of these blocks (the new version also are dynamic blocks)

 

let's say i have a host database that has a xref in and the xref contains the old blocks.

i scan the current database (AcDbBlockTableRecord) for that xref, open it and scan the xref database (AcDbBlockTableRecord) for those blocks it turn i find each block make an update insert (insert= from outside database) and replace each AcDbBlockReference. this all process work fine except the attributes at first are places

on the 0,0 position. after audit the xref and regen it, the attributes are restores in place were they should be.

 

would like to mention that i did not encounter this problem when i insert the blocks in the current database

or even replacing the symbols inside a standard block.

 

Any one knows what is my problem?

 

thanks in advance

moshe

 

Distinguished Mentor
Moshe-A
Posts: 739
Registered: ‎09-14-2003
Message 2 of 10 (166 Views)

Re: attributes are placed in 0,0 position

11-08-2012 04:10 AM in reply to: Moshe-A

foregot to mention that audit results no errors

Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 3 of 10 (160 Views)

Re: attributes are placed in 0,0 position

11-08-2012 07:20 AM in reply to: Moshe-A

Have you tried setting the database current before adding the attributes?

--
Owen Wengerd
ManuSoft
Distinguished Mentor
Moshe-A
Posts: 739
Registered: ‎09-14-2003
Message 4 of 10 (155 Views)

Re: attributes are placed in 0,0 position

11-08-2012 10:27 AM in reply to: owenwengerd

Hi Owen,

 

NO

 

What do you mean by that? to set the Xref database current?

can i do that without closing the host database?

 

thanx

Moshe

 

 

Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 5 of 10 (148 Views)

Re: attributes are placed in 0,0 position

11-08-2012 06:32 PM in reply to: Moshe-A

Yes, and yes.

--
Owen Wengerd
ManuSoft
Distinguished Mentor
Moshe-A
Posts: 739
Registered: ‎09-14-2003
Message 6 of 10 (141 Views)

Re: attributes are placed in 0,0 position

11-09-2012 12:34 AM in reply to: owenwengerd

tried it and it still doesn't work, hope i use it good (cause i have never used AcApDocumentManager)

 

here's what i did

 

ACHAR XrefFile[32= = _T("xref.dwg");
AcDbDatabase *pXref = NULL;

// allocating memory
pXref = new AcDbDatabase(Adesk::kFalse);
pXref->readDwgFile(XrefFile);		{
// switch databases
acDocManager->setCurDocument(acDocManager->document(pXref));

replace_old_symbols(pXref); // real work

// restore current database
acDocManager->setCurDocument(acDocManager->document(pCurDwg));
pXref->saveAs(XrefFile);
delete pXref; // dispose memory

 

 

i would like to understand why is this happends - do you have explanation?

 

Moshe

 

 

Distinguished Mentor
Moshe-A
Posts: 739
Registered: ‎09-14-2003
Message 7 of 10 (137 Views)

Re: attributes are placed in 0,0 position

11-09-2012 02:19 AM in reply to: Moshe-A

Owen,

 

here's a simple test is did:

 

i draw a rectangle on the current database (with RECTANGLE command)

disable the call to restore the current database

 

// acDocManager->setCurDocument(acDocManager->document(pCurDwg));

 

then build & load & run my application again

then i tried to select the rectangle and i did successed

i thought if the xref database is current i won't be able to select objects in pCurDwg

 

is this means that the call

 

acDocManager->setCurDocument(acDocManager->document(pXref))

 

is not acutally done?

 

 

 

 

Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 8 of 10 (130 Views)

Re: attributes are placed in 0,0 position

11-09-2012 07:27 AM in reply to: Moshe-A

Try instead AcDbHostApplicationServices::setWorkingDatabase().

--
Owen Wengerd
ManuSoft
Distinguished Mentor
Moshe-A
Posts: 739
Registered: ‎09-14-2003
Message 9 of 10 (127 Views)

Re: attributes are placed in 0,0 position

11-09-2012 07:49 AM in reply to: owenwengerd

Hallelujah!

 

it's working fine

 

thank you very much owen

 

i'm sure you have explanation to this and i understand it's related to display and graphics

but why does this happends only to attributes?

 

Moshe

 

Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 10 of 10 (121 Views)

Re: attributes are placed in 0,0 position

11-09-2012 08:54 AM in reply to: Moshe-A

I can only speculate that calculating text position after an alignment change requires information from the working database, and that the process is intentionally skipped or fails for some reason when the working database is different from the database of the target text object.

--
Owen Wengerd
ManuSoft

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community