Is it possible to hide an object?

Is it possible to hide an object?

hericson
Advocate Advocate
1,073 Views
10 Replies
Message 1 of 11

Is it possible to hide an object?

hericson
Advocate
Advocate
I'm writing my own lengthen dynamically function and I'm using a jig to get the new end point. What I want is to hide the line while using the jig and after getting the new end point from the jig I will unhide the line and change the line's endpoint. Is that possible or do I have to first erase the line and then recreate it after the jig has got the new end point? In that case I have to save all possible properties that I can get from the line so I can apply them to the new line object, it sounds that it's a big chance of missing something.
0 Likes
1,074 Views
10 Replies
Replies (10)
Message 2 of 11

Anonymous
Not applicable
Entity.Visible?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6368009@discussion.autodesk.com...
I'm writing my own lengthen dynamically function and I'm using a jig to get the
new end point. What I want is to hide the line while using the jig and after
getting the new end point from the jig I will unhide the line and change the
line's endpoint. Is that possible or do I have to first erase the line and then
recreate it after the jig has got the new end point? In that case I have to save
all possible properties that I can get from the line so I can apply them to the
new line object, it sounds that it's a big chance of missing something.
0 Likes
Message 3 of 11

hericson
Advocate
Advocate
Sometimes it's too easy. I was looking for something similar but searched for Hide/Unhide, Visible never occur'd to me.

But now I have a new question, look in the code below (it's not complete, I know), how can I make it invisible before calling the jig? If I use acTrans.Commit then I can't continue without errors. Do I have start a new Using?

{code}
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
lin.Visible = False

' call the jig

lin.Visible = True
acTrans.Commit()
End Using
{code}
0 Likes
Message 4 of 11

Anonymous
Not applicable
First, use the Document's TransactionManager, not the
Database's TransactionManager.

See if this works:

{code}

Document doc = ....

using( Transaction tr = doc.TransactionManager.StartTransaction () )
{
Line line = ....// assign to line to hide
using( Transaction inner = doc.TransactionManager.StartTransaction() )
{
line.Visible = false;
inner.Commit();
}

// jig here....

line.Visible = true;
tr.Commit();
}

{code}

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6368695@discussion.autodesk.com...
Sometimes it's too easy. I was looking for something similar but searched for
Hide/Unhide, Visible never occur'd to me.

But now I have a new question, look in the code below (it's not complete, I
know), how can I make it invisible before calling the jig? If I use
acTrans.Commit then I can't continue without errors. Do I have start a new
Using?

{code}
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
lin.Visible = False

' call the jig

lin.Visible = True
acTrans.Commit()
End Using
{code}
0 Likes
Message 5 of 11

hericson
Advocate
Advocate
No, it didn't work. I even tried a new Line assignment with the inner transaction but no success.
0 Likes
Message 6 of 11

Anonymous
Not applicable
I think you need to enable graphics fllush:

{code}

Document doc = ....

using( Transaction tr = doc.TransactionManager.StartTransaction () )
{
doc.TransactionManager.EnableGraphicsFlush(true);
Line line = ....// assign to line to hide
using( Transaction inner = doc.TransactionManager.StartTransaction() )
{
line.Visible = false;
inner.Commit();
}
doc.Editor.UpdateScreen();

// jig here....

line.Visible = true;
tr.Commit();
}

{code}


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6368927@discussion.autodesk.com...
No, it didn't work. I even tried a new Line assignment with the inner
transaction but no success.
0 Likes
Message 7 of 11

hericson
Advocate
Advocate
Still the same...
0 Likes
Message 8 of 11

Anonymous
Not applicable
Where are you calling the code from? A regular command,
A modeless dialog or palette?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6369577@discussion.autodesk.com...
Still the same...
0 Likes
Message 9 of 11

Anonymous
Not applicable
See the attached example.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6369577@discussion.autodesk.com...
Still the same...
0 Likes
Message 10 of 11

hericson
Advocate
Advocate
Now it works, thanks! But one conclusion is that you can't nest transactions.
0 Likes
Message 11 of 11

Anonymous
Not applicable
Actually, the hack I posted isn't necessary.

What I overlooked was that it's also necessary to call
the TransactionManager's QueueForGraphicsFlush()
method just before calling FlushGraphics().

With that change you can avoid having to repeatedly
start/commit the outermost transaction.


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2011

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6370416@discussion.autodesk.com...
Now it works, thanks! But one conclusion is that you can't nest transactions.
0 Likes