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

0 Members and 1 Guest are viewing this topic.

MickD

  • Gator
  • Posts: 3314
  • (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:");
}
}
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

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: 3314
  • (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.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

MickD

  • Gator
  • Posts: 3314
  • (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?
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

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: 3314
  • (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:");
}
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

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: 3314
  • (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.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

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: 3314
  • (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?
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

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: 3314
  • (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).
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #15 on: February 22, 2006, 08:19:52 PM »
Here's macro from the toolbutton that toggles the front clip plane, can someone make sense of it??

Code: [Select]

^C^C_dview$M=$(if,$(or,$(eq,$(getvar,tilemode),1),$(!=,$(getvar,cvport),1)),$(if,$(and,$(getvar,viewmode),2),$(if,$(and,$(getvar,viewmode),4), _all  _cl _off _cl _b _on^M, _all  _cl _off^M), _all  _cl _f $(getvar,frontz)^M)^Z)

« Last Edit: February 22, 2006, 08:30:49 PM by MickD »
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Turn off clipping planes in current view
« Reply #16 on: February 22, 2006, 08:30:15 PM »
Yes, but they are just parameters to the DVIEW command, dependant on MSpace/Pspace settings.

only usefull if you were to use SendCommand ...
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: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #17 on: February 22, 2006, 08:35:41 PM »
Thanks Kerry.

I think the clue is in the code posted by Luis earlier in that the record is not added to the  view table and therefore not a 'saved' view, it's just used to set up params for a view to be passed to the global function to set the camera up.

It really looks as though I'll have to set up my own view tools but that's ok as I can create a .cfg file to let the user set them up a little different if required.

Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Chuck Gabriel

  • Guest
Re: Turn off clipping planes in current view
« Reply #18 on: February 22, 2006, 08:43:25 PM »
This works for paperspace viewports.  Not exactly what you were looking for I know, but maybe somebody will find a use for it.

Code: [Select]
//
// ObjectARX defined commands

#include "StdAfx.h"
#include "StdArx.h"
#include "dbents.h"
#include "dbobjptr.h"

void cgabClipPlanesViewUnclipped() {
AcDbObjectId curVpId = acedGetCurViewportObjectId();
AcDbObjectPointer<AcDbViewport> pVport(curVpId, AcDb::kForWrite);
if(pVport.openStatus() != Acad::eOk) {
acutPrintf("\nUnable to retrieve current viewport");
return;
}
pVport->setBackClipOff();
pVport->setFrontClipOff();
pVport->updateDisplay();
}

void cgabClipPlanesViewClipped() {
AcDbObjectId curVpId = acedGetCurViewportObjectId();
AcDbObjectPointer<AcDbViewport> pVport(curVpId, AcDb::kForWrite);
if(pVport.openStatus() != Acad::eOk) {
acutPrintf("\nUnable to retrieve current viewport");
return;
}
pVport->setBackClipOn();
pVport->setFrontClipOn();
pVport->updateDisplay();
}

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #19 on: February 22, 2006, 08:47:11 PM »
Thanks Chuck, that will come in handy real soon :)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #20 on: February 22, 2006, 09:26:19 PM »
Here's what I'll be using as a base for my own iso views etc. Just change the vector values to change the viewing direction.
Code: [Select]
static void View_swiso(void)
{
// function to set an sw-iso view with clip planes turned off
// you would normally use this or similar functions when coming
// out of a named view that could possibly have the clipping planes
// turned on. Example only...use at your own risk! MickD Feb 2006

AcDbViewTableRecord view; //temp view object
AcGeVector3d* viewDirVec = new AcGeVector3d(-1.0,-1.0,1.0);
struct resbuf rb;
acedGetVar("TILEMODE", &rb);
int tilemode = rb.resval.rint;
acedGetVar("CVPORT", &rb);
int cvport = rb.resval.rint;

// set Paperspace flag
bool paperspace = ((tilemode == 0) && (cvport == 1)) ? Adesk::kTrue : Adesk::kFalse;
view.setIsPaperspaceView(paperspace);
if (Adesk::kFalse == paperspace)
{
view.setFrontClipEnabled(false);
view.setBackClipEnabled(false);
view.setViewDirection(*viewDirVec);
acedSetCurrentView(&view,NULL); //set it!
// a work around for a lot of code for now ;)
acedCommand(RTSTR, "_zoom", RTSTR, "_extents", RTNONE);
}
else
{
acutPrintf("\nCan't turn off clipping planes in paperspace!");
}

}
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Turn off clipping planes in current view
« Reply #21 on: February 22, 2006, 09:45:11 PM »
Quote
         // a work around for a lot of code for now ;)
         acedCommand(RTSTR, "_zoom", RTSTR, "_extents", RTNONE);

hehehehehe ....
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: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #22 on: February 22, 2006, 10:08:23 PM »
heh, You like that Kerry :)

Truth be known, that is probably safer than anything I could write to do the same thing but I will do the exercise when time permits ;)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #23 on: February 22, 2006, 10:15:39 PM »
Seek and you shall recieve!
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Bryco

  • Water Moccasin
  • Posts: 1850
Re: Turn off clipping planes in current view
« Reply #24 on: February 23, 2006, 12:46:57 AM »
Mick is the name Active or *Active. The express database viewer calls it the latter. If so does arx accept "*Active" or is it "`*Active"

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #25 on: February 23, 2006, 01:00:40 AM »
Thanks Bryco, I'll just having a look now, I'll probably have to try both the view and viewport objects to see what happens but I'm guessing it will be a viewport object in mspace.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #26 on: February 23, 2006, 01:38:20 AM »
Nope, no good.
I'm actually resigned to creating my own view tools anyway so that it eliminates the extra command to unclip once you've changed views and it allows views to be slightly off perfect iso so that you can see all the lines without them being hidden behind others as is the case with the std view settings.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Bill::Meat4Brains

  • Guest
Re: Turn off clipping planes in current view
« Reply #27 on: February 23, 2006, 02:28:07 PM »
Rather than turn it off...  What about just moving the clipping plane?  Have you tried that?

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #28 on: February 23, 2006, 03:50:06 PM »
Rather than turn it off... What about just moving the clipping plane? Have you tried that?

Hi Bill::
The problem is that they are still on in an isometric view after being in a ortho type view that had them on. Moving them would work but would involve a few extra commands. I could just use the 3dorbit toolbar and turn them off (my work around at the moment) but I want it to seem more natural to the user that when they switch to a std view it will be as expected.
What I'm trying to do is create saved views that can be used when needed in a 3d model to eliminate the 'noise' of other objects at that particular place in the model (say a section), this makes it easier to see what you are working on. These views will also be available when creating viewports in paper space for documentation so you can have clipped sections and plans in your drgs without having to set them up, just use the saved view for the viewport.
If you download the drg I attached in a previous post and set the saved view and you would see what I mean, try different iso views and it can get pretty bad.
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

Bryco

  • Water Moccasin
  • Posts: 1850
Re: Turn off clipping planes in current view
« Reply #29 on: February 23, 2006, 10:34:02 PM »
acedVports2VportTableRecords() was mentioned here  http://discussion.autodesk.com/thread.jspa?forumID=33&threadID=455267 just to muddy it up further.

MickD

  • Gator
  • Posts: 3314
  • (x-in)->[process]->(y-out)
Re: Turn off clipping planes in current view
« Reply #30 on: February 23, 2006, 10:43:32 PM »
Yep, I had a go at that too but my patience had run out :D
I will investigate this further though, it's easy to get confused as you can have viewports in both mspace/pspace and in mspace you are really only looking through a single viewport (when not in multiple views).
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”