Author Topic: Turn off clipping planes in current view  (Read 11086 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Turn off clipping planes in current view
« on: February 22, 2006, 01:09:39 AM »
I'm trying to turn of the clipping planes of the current view. If I set my view to a named view that I created with clipping on and then select one of the standard views it still shows the clipping planes 'on'. If I look in the views dialog->view settings I can see that the clip planes are on even after I run this code.
Is there another way I need to get the current view or do I need another way to turn clipping off?

TIA,
Mick.

Code: [Select]

static void DCSDCSARX3dunclip(void)
{
// function to turn the clip planes off after being
// in a clipped view. Use current view to change settings
AcDbViewTable* pVt;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pVt, AcDb::kForWrite);
if (!pVt->has("Current"))
{
AcDbViewTableRecord* pVtrec = new AcDbViewTableRecord;
pVt->getAt("Current", *&pVtrec,AcDb::kForWrite,false);
pVtrec->setFrontClipEnabled(false);
pVtrec->setBackClipEnabled(false);
pVtrec->close();
pVt->close();
acutPrintf("\nDone:");
}
else
{
pVt->close();
acutPrintf("\nFailed to turn off clipping, try again:");
}
}
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

Chuck Gabriel

  • Guest
Re: Turn off clipping planes in current view
« Reply #1 on: February 22, 2006, 07:43:16 AM »
Are you displaying the view while in tilemode 1, or inside a viewport from tilemode 0?

LE

  • Guest
Re: Turn off clipping planes in current view
« Reply #2 on: February 22, 2006, 09:32:16 AM »
I found this code on the other side:

Code: [Select]
void ArxZoom(ads_point pt, double magnf)
{
AcDbViewTableRecord view;
struct resbuf rb;
struct resbuf wcs, dcs, ccs; // acedTrans coord system flags
ads_point vpDir;
ads_point ptmax;
AcGeVector3d viewDir;
AcGePoint2d cenPt;
ads_real lenslength, viewtwist, frontz, backz;
ads_point target;
int /*viewmode,*/tilemode, cvport; // Get window to zoom to:
wcs.restype = RTSHORT; // WORLD coord system flag
wcs.resval.rint = 0;
ccs.restype = RTSHORT; // CURRENT coord system flag
ccs.resval.rint = 1;
dcs.restype = RTSHORT; // DEVICE coord system flag
dcs.resval.rint = 2; // Get the VPOINT' direction vector

acedGetVar("VIEWDIR", &rb);
acedTrans(rb.resval.rpoint, &ccs, &wcs, 0, vpDir);
viewDir.set(vpDir[X], vpDir[Y], vpDir[Z]);
acedTrans(pt, &ccs, &dcs, 0, ptmax);

// set center point of view
cenPt[X] = ptmax[X];
cenPt[Y] = ptmax[Y];
view.setCenterPoint(cenPt);
view.setHeight(magnf*1.2);
view.setWidth(magnf*1.2);
view.setViewDirection(viewDir);

// get and set other properties
acedGetVar("LENSLENGTH", &rb);
lenslength = rb.resval.rreal;
view.setLensLength(lenslength);

acedGetVar("VIEWTWIST", &rb);
viewtwist = rb.resval.rreal;
view.setViewTwist(viewtwist);

acedGetVar("FRONTZ", &rb);
frontz = rb.resval.rreal;

acedGetVar("BACKZ", &rb);
backz = rb.resval.rreal;
view.setPerspectiveEnabled(false);
view.setFrontClipEnabled(false);
view.setBackClipEnabled(false);
view.setFrontClipAtEye(false);

acedGetVar("TILEMODE", &rb);
tilemode = rb.resval.rint;

acedGetVar("CVPORT", &rb);
cvport = rb.resval.rint;

// Paperspace flag
bool paperspace = ((tilemode == 0) && (cvport == 1)) ? Adesk::kTrue:Adesk::kFalse;
view.setIsPaperspaceView(paperspace);
if (Adesk::kFalse == paperspace) {
view.setFrontClipDistance(frontz);
view.setBackClipDistance(backz);
}
else{
view.setFrontClipDistance(0.0);
view.setBackClipDistance(0.0);
}
acedGetVar("TARGET", &rb);
acedTrans(rb.resval.rpoint,&ccs, &wcs, 0, target);
view.setTarget(AcGePoint3d(target[X], target[Y], target[Z]));
// update view
acedSetCurrentView(&view, NULL);

}

Might be useful...

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #3 on: February 22, 2006, 03:44:16 PM »
Are you displaying the view while in tilemode 1, or inside a viewport from tilemode 0?

In modelspace Chuck - (TILEMODE = 1).

Luis, thanks for that, experimenting with that now.
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #4 on: February 22, 2006, 04:13:54 PM »
I used some code from above to get the tilemode etc then set the clipping planes false, no go. I then tried the same and using acedSetCurrentView() but it completely changed the view although it did turn off the clip planes ??

Maybe I'll have to set up my own tool bar for standard views?
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

LE

  • Guest
Re: Turn off clipping planes in current view
« Reply #5 on: February 22, 2006, 04:18:35 PM »
I am out of help... here... In the type of work I do, never had used or needed to implement something like this...

[work type: cleaning car windows on the streets.....  :lmao:]

a dwg my help to me better than 1000 words....  :-D

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #6 on: February 22, 2006, 04:36:56 PM »
Ok, here's a dwg attached with a named view with a clipping plane. Set the view as current then select one of the iso views to take it back and you will see the clip plane cut out some details.
Copy and paste the code below into a new arx command, try uncommenting the acedSetCurrentView and see what it does.
Thanks.
Code: [Select]
// function to turn the clip planes off after being
// in a clipped view. Use current view to change settings
AcDbViewTable* pVt;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pVt, AcDb::kForWrite);
if (!pVt->has("CURRENT"))
{
AcDbViewTableRecord* pVtrec = new AcDbViewTableRecord;
pVt->getAt("CURRENT", *&pVtrec,AcDb::kForWrite,false);
struct resbuf rb;
acedGetVar("TILEMODE", &rb);
int tilemode = rb.resval.rint;

acedGetVar("CVPORT", &rb);
int cvport = rb.resval.rint;

// Paperspace flag
bool paperspace = ((tilemode == 0) && (cvport == 1)) ? Adesk::kTrue : Adesk::kFalse;
pVtrec->setIsPaperspaceView(paperspace);
if (Adesk::kFalse == paperspace)
{
pVtrec->setFrontClipEnabled(false);
pVtrec->setBackClipEnabled(false);
acutPrintf("\nDone:");
}
else
{
acutPrintf("\nCan't turn off clipping planes in paperspace!");
}
//acedSetCurrentView(pVtrec,NULL);//<-- un-comment to try me!
pVtrec->close();
pVt->close();

}
else
{
pVt->close();
acutPrintf("\nFailed to turn off clipping, try again:");
}
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

LE

  • Guest
Re: Turn off clipping planes in current view
« Reply #7 on: February 22, 2006, 05:42:15 PM »
nope... it always go to PLAN view.... strange.

Chuck Gabriel

  • Guest
Re: Turn off clipping planes in current view
« Reply #8 on: February 22, 2006, 05:46:00 PM »
In modelspace Chuck - (TILEMODE = 1).

I was thinking perhaps the properties of the AcDbViewport object were taking precedence over the properties of the AcDbViewTableRecord.

I'll take a closer look, and see if I can figure it out.

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #9 on: February 22, 2006, 05:57:04 PM »
In another app I use you can set a view with clip planes on and if you use the std isoviews to go back and view whole drg it does the same thing, the only way to get it back to normal is to use their predefined view tools and then use the std ones if you want. Maybe I'll have to do the same but just create a std plan view of model extents ?

I'm really surprised that you have a global function to 'set' the current view but not 'get' the current view.
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

LE

  • Guest
Re: Turn off clipping planes in current view
« Reply #10 on: February 22, 2006, 06:11:10 PM »
Mick;

I did a test using a different view name and does not go to PLAN view...

LE

  • Guest
Re: Turn off clipping planes in current view
« Reply #11 on: February 22, 2006, 06:20:19 PM »
Mick;

I did a test using a different view name and does not go to PLAN view...

does not work.... false alarm...

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #12 on: February 22, 2006, 06:21:19 PM »
If you give it a view name that exists in the view table it will only switch off the planes for that view and leave other settings as is. What I need to get is the current view that may not be in the named views table and set it's planes to 'off' but getting the actual view (that is probably not in the table and hard coded into acad and set with acedSetCurrentView and param's given by user input etc.
If you have a look at the code you posted above it doesn't add the view to the views table, just sets some param's for a temp view and uses the global function to set it.
I may have to go the same way?
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Turn off clipping planes in current view
« Reply #13 on: February 22, 2006, 07:50:55 PM »
void
   setFrontClipEnabled(
      bool enabled);


is this the one you need ?

Acad::ErrorStatus
   setFrontClipOff();

Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

MickD

  • Gator
  • Posts: 3289
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #14 on: February 22, 2006, 08:09:37 PM »
No good I'm afraid, I tried getting the current view and co-ercing it as a viewport and checking tilemode etc and using those functions but no good.

I'm about to have a look in the menu scripts to see how they turn it off when in 3dorbit mode (here you can switch them off 1 at a time).
Debugging:
Being the detective in a crime movie where you're also the murderer.

“Someone's sitting in the shade today because someone planted a tree a long time ago.”
- Warren Buffet