ObjectARX

Reply
Distinguished Mentor
835 Posts
38 Kudos
Registered: ‎09-14-2003
Post 1 of 9
Accepted Solution

downClose an object

140 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

 

 

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

Distinguished Mentor
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 2 of 9

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
835 Posts
38 Kudos
Registered: ‎09-14-2003
Post 3 of 9

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
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 4 of 9

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
835 Posts
38 Kudos
Registered: ‎09-14-2003
Post 5 of 9

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
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 6 of 9

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
835 Posts
38 Kudos
Registered: ‎09-14-2003
Post 7 of 9

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
739 Posts
100 Kudos
Registered: ‎08-06-2002
Post 8 of 9

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
835 Posts
38 Kudos
Registered: ‎09-14-2003
Post 9 of 9

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

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!