ObjectARX

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

downClose an object

128 Views, 8 Replies
10-24-2012 02:55 PM

Guys,

 

some where in the docs i saw there is a way to downClose an object if it is had multireaders

 

How?

 

thanX

moshe

 

 

Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 2 of 9 (120 Views)

Re: downClose an object

10-24-2012 07:57 PM in reply to: Moshe-A

It has nothing to do with multiple readers, but maybe you are thinking of downgradeOpen().

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

Re: downClose an object

10-24-2012 11:23 PM in reply to: owenwengerd

Owen hi,

 

No i thought about AcDbObject::isReallyClosing() but this does not solved the problem i encounter...

 

i have a dynamic block (inserted in ) with 3 Visibility options and i want to set it but always gets

eHadMultipleReaders error so i thought the AcDbBlockReference is opened more than one time

but with AcDbObject::isReallyClosing() it turns out it is open only one

 

here is the function i call to do that....BlkRefId is the block id that is open for read only once

openDirValue has the new value to set

 

 

bool setDynamicBlockPropertyValue(AcDbObjectId BlkRefId, AcDbEvalVariant openDirValue)

{
  AcDbDynBlockReferencePropertyArray DynBlkRefPropArray;
  DynBlkRefPropArray.setLogicalLength(0);

  AcDbDynBlockReference DynBlkRef(BlkRefId);
  DynBlkRef.getBlockProperties(DynBlkRefPropArray);

  AcDbDynBlockReferenceProperty DynBlockReferenceProp;

  for (inti = 0; i < DynBlkRefPropArray.length(); i++)
  {
    DynBlockReferenceProp = DynBlkRefPropArray.at(i);

     if (DynBlockReferenceProp.propertyName() == _T("Visibility") &&
         DynBlockReferenceProp.propertyType() == AcDbEvalVariant::kString &&
         DynBlockReferenceProp.readOnly() ==  false&&
         DynBlockReferenceProp.show() ==  true)
     {
        DynBlockReferenceProp.setValue(openDirValue); // set visibility returns eHadMultipleReaders

       return true;
     } 
  }

  return false;
}



 

Moshe

 

 

Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 4 of 9 (107 Views)

Re: downClose an object

10-25-2012 08:59 AM in reply to: Moshe-A

Why did you leave the BlkRefId object open for read? Did you try closing it before calling setDynamicBlockPropertyValue()?

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

Re: downClose an object

10-25-2012 11:10 AM in reply to: owenwengerd

Owen

 

As always you got the sharp senses...you are the one of the bests.

 

thank you very much

moshe

 

Distinguished Mentor
owenwengerd
Posts: 614
Registered: ‎08-06-2002
Message 6 of 9 (96 Views)

Re: downClose an object

10-25-2012 11:26 AM in reply to: Moshe-A

Thank you. BTW, based on your usage of the function arguments, you should change the function signature like so:

bool setDynamicBlockPropertyValue(const AcDbObjectId& BlkRefId, const AcDbEvalVariant& openDirValue)

 

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

Re: downClose an object

10-26-2012 12:24 AM in reply to: owenwengerd

why? i do not set these arguments in getDynamicBlockPropertyValue() and do not need them in the caller

 

but i do have an issue with openDirValue...

here is what i do before calling setDynamicBlockPropertyValue()

 

 

AcDbEvalVariant openDirValue;
AcDbObjectId ObjId = pEnt->objectId();
pEnt->close();

getDynamicBlockPropertyValue(ObjId, openDirValue)

if (_tcsicmp(openDirValue.resval.rstring, _T("Left Openning")) == NULL)
  openDirValue = _T("Right Openning");
else
 if (_tcsicmp(openDirValue.resval.rstring, _T("Right Openning")) == NULL)
   openDirValue = _T("Left Openning");

setDynamicBlockPropertyValue(ObjId, openDirValue);




 

the compare with openDirValue string value fails because is contains a space.

how can i solve it?  (i prefer to keep the visibility options as the are)

 

moshe

 

 

 

 

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

Re: downClose an object

10-26-2012 06:34 AM in reply to: Moshe-A

The arguments should be const because you're not changing them, and by reference so you don't create and discard copies for no reason. I doubt that the space has any bearing on your string comparison. I think the misspelled word "Opening" is more likely the reason.

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

Re: downClose an object

10-26-2012 08:24 AM in reply to: owenwengerd

Ok i accept your rermark on const and by reference

 

regarding openDirValue, for a while instead of space i put there a dash and  it start to work

after a while it stops working although DynBlockReferenceProp.setValue(openDirValue) returns

Acad::eOk do not know why? or how? it was frustrating...

 

after you turned my attention for the misspelled 'openning' i also removed the dash and restored the space

there i discoved that there was and extra space in the visibility parameter (you can not see it by eye)

than i fix it it its now working :smileyvery-happy:

 

again, thank you very much for your help, i turly appreciate it.

Moshe

 

 

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