Hi to all,
I'd like to have a block that when The user rotate the block I can call automatically a custom function and print of how much degrees is rotated. Could you give me some examples or idea ?
Best Regards,
Marco
Solved! Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
Solved by Alexander.Rivilis. Go to Solution.
Hi @Alexander.Rivilis ,
I only need to call this function to get the total rotation ?
This method should be called in :
void modified(const AcDbObject* dbObj) {
or in:
void openedForModify(const AcDbObject* dbObj) {
?
Can you show me how to write this function please ?
Best Regards,
Marco
Hi @Alexander.Rivilis and @tbrammer ,
the code now is working thank you but I'm troubling with xdata editing in the reactor's methods:
void ReattoreRotazione::openedForModify(const AcDbObject * dbObj)
{
acutPrintf(L"APERTO PER MODIFICA\n");
AcDbObjectId objId;
objId = dbObj->objectId();
AcDbObjectPointer<AcDbBlockReference> bref(objId, AcDb::kForRead);
acutPrintf(L"MODIFIED\n");
if (bref.openStatus() == Acad::eOk) {
acutPrintf(L"SONO QUI\n");
Adesk::Boolean write = Adesk::kTrue;
bref->upgradeFromNotify(write);
deleteXdataRecord(bref);
}
}
2. I was thinking that bref->upgradeFromNotify was usefull to edit metadata but seems not work properly because when I call bref->setXdata(appNAme) i got : Exception thrown at 0x00007FFB5755DA32 (mscordacwks.dll) in acad.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
void ReattoreRotazione::modified(const AcDbObject * dbObj)
{
AcDbObjectId objId;
objId = dbObj->objectId();
AcDbObjectPointer<AcDbBlockReference> bref(objId, AcDb::kForRead);
acutPrintf(L"MODIFIED\n");
if (bref.openStatus() == Acad::eOk) {
acutPrintf(L"DENTRO\n");
bref->rotation();
acutPrintf(L"Rotazione di: \n");
acutPrintf(ACRX_T("%f"), bref->rotation());
acutPrintf(L"Radianti");
Adesk::Boolean write = Adesk::kTrue;
bref->upgradeFromNotify(write);
writeRotation(bref);
}
else {
acutPrintf(L"NOPE\n");
}
}
and the skeleton for writeRotation() function is :
void ReattoreRotazione::writeRotation(AcDbBlockReference* bref) {
resbuf *rb = acutBuildList(
AcDb::kDxfRegAppName, myAppName,
0
);
if (bref->setXData(rb) == Acad::eOk) {
acutPrintf(L"SCRITTO\n");
}
else {
acutPrintf(L"NON SCRITTO\n");
}
}
3. The reactor is invoked for every action performed on my BlockReference, could I trigger my reactor after rotate command ?
Thank You,
Marco
@Anonymous
It is impossible change entity in openedForModify. That is why I've proposed using AcDbTransformOverrule.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi @Alexander.Rivilis ,
Probably I didn't explain well what I would like to do and therefore I didn't understand that your solution was the correct one. I have defined a block and I would like that if an user rotates a blockreference of this block automatically will start an automatic mechanism whereby in an xdata connected with the blockreference it maintains the total angle of rotation starting from the initial position of the block. How can I achieve this goal?
Best Regards,
Marco
@Anonymous
1. I do not understand why store in xdata rotation angle if you can get this value at any time using the rotation() method.
2. If you like to change xdata while block reference rotated you can use AcDbTransformOverrule::transformBy. This method will be called after block reference rotation/move/scale. You need only call AcDbBlockReference::rotation() method and write this data to xdata.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Rightly it is not clear to you what I intend to do because it is not strictly connected with Autocad but thank you for your patience. 🙂
1)I wanted to understand how I could intercept through a reactor any type of operation performed on a certain block reference, rotation was an example, but I was also thinking about elongation, displacement, etc. and store displacements or rotations in some memory unit
2)About these two functions you are mentioning where should I write them? I would like them to be incorporated by all the block references of the "car" block and not to other blocks.
Thank you,
Marco
@Anonymous wrote:
2)About these two functions you are mentioning where should I write them? I would like them to be incorporated by all the block references of the "car" block and not to other blocks.
You have to derive your class from AcDbTransformOverrule and override method AcDbTransformOverrule::transformBy
Sample of using AcDbTransformOverrule is https://adndevblog.typepad.com/autocad/2012/06/locking-an-entity-in-autocad-using-objectarx.html
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Adding on my arcEntry point MyOverruleClass::rxinit(); I got this error:
Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol "public: static void __cdecl OverruleRotation::rxInit(void)" (?rxInit@OverruleRotation@@SAXXZ) referenced in function "public: virtual enum AcRx::AppRetCode __cdecl COverruleApp::On_kInitAppMsg(void *)" (?On_kInitAppMsg@COverruleApp@@UEAA?AW4AppRetCode@AcRx@@PEAX@Z) Overrule C:\Users\Marco\source\repos\Overrule\Overrule\acrxEntryPoint.obj 1
Have you in declaration of class OverruleRotation next line:
ACRX_DECLARE_MEMBERS(OverruleRotation);
and next line out of declaration class:
ACRX_NO_CONS_DEFINE_MEMBERS(OverruleRotation, AcDbTransformOverrule);
???
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi @Alexander.Rivilis ,
I was missing secondo statement :-). But the code still not working 😞
#pragma once
#include "dbentityoverrule.h"
class OverruleRotation :
public AcDbTransformOverrule
{
public:
static OverruleRotation* _pTheOverrule;
ACRX_DECLARE_MEMBERS(OverruleRotation);
bool isApplicable(const AcRxObject* pOverruledSubject) const
{
return true;
}
Acad::ErrorStatus transformBy(AcDbEntity* pSubject,const AcGeMatrix3d& xform)
{
if (pSubject->isA() != AcDbCircle::desc()) {
return Acad::eOk;
}
AcDbCircle* pCircle = AcDbCircle::cast(pSubject);
if (pCircle != NULL) {
return Acad::eNotApplicable;
}
return AcDbTransformOverrule::transformBy(pSubject, xform);
}
static void OverruleRotation::AddOverrule()
{
if (_pTheOverrule != NULL)
return;
_pTheOverrule = new OverruleRotation();
AcRxOverrule::addOverrule(AcDbCircle::desc(),_pTheOverrule,true);
OverruleRotation::setIsOverruling(true);
}
static void OverruleRotation::RemoveOverrule()
{
if (_pTheOverrule == NULL)
return;
OverruleRotation::setIsOverruling(false);
AcRxOverrule::removeOverrule(
AcDbCircle::desc(),
_pTheOverrule
);
delete _pTheOverrule;
_pTheOverrule = NULL;
}
};
ACRX_NO_CONS_DEFINE_MEMBERS(OverruleRotation, AcDbTransformOverrule);
Kindly Regards,
Marco
@Anonymous
Post you full solution as a zip-file.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi @Alexander.Rivilis , i'm not able to upload the zip on the forum.
This is a link for my google drive zip containing project.
Thank You,
Marco
@Anonymous wrote:
Hi @Alexander.Rivilis , i'm not able to upload the zip on the forum.
This is because your zip-file contains a huge amount of unnecessary waste, which must be removed.
For example, subfolders .vs, x64, Debug have to be delete before zip. After that yours zip-file have to be 16987 byte long.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Remove OverruleRotation.cpp from your project.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
I created this utility to zip a vs project, this can be applied to any VS project.
create a bat file with below contents and name it mkzip.bat
Replace this with attached file C:\UtilStuff\bin\vsExclude.txt
or you download the zip package containing mkzip.bat
and vsExclude.txt
::mkzip::
::Assume we have string set M=Madhukar
::To extrapolate first char of variable %M:~0,1%
::echo %M:~0,1% will give M
::To extrapolate last char of variable %M:~-1%"
::echo %M:~-1%" will give r
::To extrapolate 4th char of variabke %M:~4,1%
::echo %M:~4,1% will give u
@echo off
echo Running %~nx0
echo/
echo Current directory is: %CD%
echo Directory of %~nx0 is: %~dp0
for /f %%i in ("%CD%") do set p=%%~ni
set yy=%DATE:~-4%
set mm=%DATE:~4,2%
set dd=%DATE:~7,2%
set h=%TIME:~0,2%
set m=%TIME:~3,2%
set s=%TIME:~6,2%
set zip="%yy%-%mm%-%dd%_%h%_%m%_%s%_%p%.zip"
echo Zip Name is : %zip%
7z.exe a -tzip "%zip%" "%CD%\*" -bd -mx9 -xr@"C:\UtilStuff\bin\vsExclude.txt"
Note: make sure you have 7z on your path
Ascii Recording
Hi @Alexander.Rivilis , thank your for your solution, was the probleme the presence of a cpp classe ?
Now It still not working because when i call OverruleRotation::AddOverrule(); I got this error:
Severity Code Description Project File Line Suppression State
Error LNK2001 unresolved external symbol "public: static class OverruleRotation * OverruleRotation::_pTheOverrule" (?_pTheOverrule@OverruleRotation@@2PEAV1@EA) Overrule C:\Users\Marco\Downloads\Overrule\Overrule\Overrule\acrxEntryPoint.obj 1
Thank you,
Marco
In file OverruleRotation.h after line:
ACRX_NO_CONS_DEFINE_MEMBERS(OverruleRotation, AcDbTransformOverrule);
add line:
OverruleRotation* OverruleRotation::_pTheOverrule;
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
Hi @Alexander.Rivilis ,
only a little question about method transformBy() :
Can I undestrand if this function it is invoked by a rotation or a scale or a move command or something else ?
K.R.
Marco
1. One way is analyzing transform matrix.
For example,
2. Second way is checking command name. Function acedGetCommandForDocument can help you.
Відповідь корисна? Клікніть на "ВПОДОБАЙКУ" цім повідомленням! | Do you find the posts helpful? "LIKE" these posts!
Находите сообщения полезными? Поставьте "НРАВИТСЯ" этим сообщениям!
На ваше запитання відповіли? Натисніть кнопку "ПРИЙНЯТИ РІШЕННЯ" | Have your question been answered successfully? Click "ACCEPT SOLUTION" button.
На ваш вопрос успешно ответили? Нажмите кнопку "УТВЕРДИТЬ РЕШЕНИЕ"
Alexander Rivilis / Александр Ривилис / Олександр Рівіліс
Programmer & Teacher & Helper / Программист - Учитель - Помощник / Програміст - вчитель - помічник
Facebook | Twitter | LinkedIn
could you show me an online sample of if statement using acedGetCommandForDocument ?
Than you,
Marco
Can't find what you're looking for? Ask the community or share your knowledge.