Author Topic: Vertical TextStyle Function  (Read 2064 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
Vertical TextStyle Function
« on: April 24, 2006, 11:33:20 PM »
Here is a function to change the vertical property for a textstyle.

Code: [Select]
static int ads_verticaltextstyle(void) {
struct resbuf *pArgs = acedGetArgs();
char pTextName [256];
if (pArgs && pArgs->restype == RTSTR) {
strcpy(pTextName, pArgs->resval.rstring);
//acDocManager->lockDocument(acDocManager->curDocument());
AcDbTextStyleTableRecordPointer pTextStyle(pTextName,acdbCurDwg(),AcDb::kForWrite);
Acad::ErrorStatus es = pTextStyle.openStatus();
if ((es == Acad::eOk) && !pTextStyle->isVertical()) {
//pTextStyle->upgradeOpen();
pTextStyle->setIsVertical(Adesk::kTrue);
acedRetT();
} else {
acedRetNil();
}
}
return (RSRSLT);
}

LE

  • Guest
Re: Vertical TextStyle Function
« Reply #1 on: April 25, 2006, 12:06:44 AM »
Here another version [have not tested myself]

Now, it will include a new argument to turn on and off the Isvertical property [but wait for the masters].

 :-)

Code: [Select]
static int ads_verticaltextstyle(void) {
struct resbuf *pArgs = acedGetArgs();
Acad::ErrorStatus es;
char pTextName [256];
short flag;
if (pArgs && pArgs->restype == RTSTR && pArgs->rbnext && pArgs->rbnext->restype == RTSHORT) {
strcpy(pTextName, pArgs->resval.rstring);
flag = pArgs->resval.rint;
if (flag != 0 || flag != 1) acedRetNil();
AcDbTextStyleTableRecordPointer pTextStyle(pTextName,acdbCurDwg(),AcDb::kForWrite);
if (pTextStyle.openStatus() == Acad::eOk) {
switch(flag) {
case 1:
if (!pTextStyle->isVertical()) {
pTextStyle->setIsVertical(Adesk::kTrue);
acedRetT();
} else {
acedRetNil();
}
break;
case 0:
if (pTextStyle->isVertical()) {
pTextStyle->setIsVertical(Adesk::kFalse);
acedRetT();
} else {
acedRetNil();
}
break;
}
}
}
return (RSRSLT);
}

Alexander Rivilis

  • Bull Frog
  • Posts: 212
  • Programmer from Kyiv (Ukraine)
Re: Vertical TextStyle Function
« Reply #2 on: April 25, 2006, 07:51:11 AM »
First of all change:
Code: [Select]
flag = pArgs->resval.rint;with:
Code: [Select]
flag = pArgs->rbnext->resval.rint;Also it will be useful return 0 or 1 dependency on pTextStyle->isVertical() and nil if parameters are wrong or another error in function:
Code: [Select]
acedRetNil(); // In begining of function;
Code: [Select]
acedRetInt(pTextStyle->isVertical()); // In end of function
:)

LE

  • Guest
Re: Vertical TextStyle Function
« Reply #3 on: April 25, 2006, 08:57:28 AM »
Oops...

I'm about to check the function right now, I wrote the code late last night [blind].

Thanks.

LE

  • Guest
Re: Vertical TextStyle Function
« Reply #4 on: April 25, 2006, 09:32:29 AM »
Here is the updated function:

Code: [Select]
static int ads_verticaltextstyle(void) {
struct resbuf *pArgs = acedGetArgs();
Acad::ErrorStatus es;
char pTextName [256];
short flag;
if (pArgs && pArgs->restype == RTSTR &&
pArgs->rbnext && pArgs->rbnext->restype == RTSHORT) {
strcpy(pTextName, pArgs->resval.rstring);
flag = pArgs->rbnext->resval.rint;
if (flag == 0 || flag == 1) {
AcDbTextStyleTableRecordPointer pTextStyle(
pTextName,acdbCurDwg(),AcDb::kForWrite);
if (pTextStyle.openStatus() == Acad::eOk) {
switch(flag) {
case 1:
if (!pTextStyle->isVertical())
pTextStyle->setIsVertical(Adesk::kTrue);
acedRetInt(pTextStyle->isVertical());
break;
case 0:
if (pTextStyle->isVertical())
pTextStyle->setIsVertical(Adesk::kFalse);
acedRetInt(pTextStyle->isVertical());
break;
}
}
}
else { acedRetNil(); }
}
return(RSRSLT);
}
« Last Edit: April 26, 2006, 10:41:36 AM by LE »