ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

downClose an object

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
Moshe-A
498 Views, 8 Replies

downClose an object

Guys,

 

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

 

How?

 

thanX

moshe

 

 

8 REPLIES 8
Message 2 of 9
owenwengerd
in reply to: Moshe-A

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

--
Owen Wengerd
ManuSoft
Message 3 of 9
Moshe-A
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

 

 

Message 4 of 9
owenwengerd
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
Message 5 of 9
Moshe-A
in reply to: owenwengerd

Owen

 

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

 

thank you very much

moshe

 

Message 6 of 9
owenwengerd
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
Message 7 of 9
Moshe-A
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

 

 

 

 

Message 8 of 9
owenwengerd
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
Message 9 of 9
Moshe-A
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 Smiley Very Happy

 

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

Moshe

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost