Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get viewport Type

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
anhtrung
890 Views, 8 Replies

Get viewport Type

anhtrung
Advocate
Advocate

i want get viewport type in Layout. so can everybody help me please? Thks

0 Likes

Get viewport Type

i want get viewport type in Layout. so can everybody help me please? Thks

8 REPLIES 8
Message 2 of 9
Jeff_M
in reply to: anhtrung

Jeff_M
Consultant
Consultant
Accepted solution

This is found in the Viewport's Xdata:

    public static class ViewportExtensions
    {
        /// <summary>
        /// Returns the Viewort type:
        /// 0 = undefined,
        /// 1 = Plan,
        /// 2 = Profile,
        /// 3 = Section
        /// </summary>
        /// <param name="vp"></param>
        /// <returns></returns>
        public static short GetViewportType(this Viewport vp)
        {
            short vptype = 0;
            var xArray = vp.XData.AsArray();
            int i = -1;
            foreach (TypedValue tv in xArray)
            {
                i++;
                try
                {
                    if ((string)tv.Value == "AeccPlanProd50ViewportType")
                    {
                        vptype = (short)xArray[i + 1].Value;
                        break;
                    }
                }
                catch { }
            }
            return vptype;
        }
Jeff_M, also a frequent Swamper
EESignature

This is found in the Viewport's Xdata:

    public static class ViewportExtensions
    {
        /// <summary>
        /// Returns the Viewort type:
        /// 0 = undefined,
        /// 1 = Plan,
        /// 2 = Profile,
        /// 3 = Section
        /// </summary>
        /// <param name="vp"></param>
        /// <returns></returns>
        public static short GetViewportType(this Viewport vp)
        {
            short vptype = 0;
            var xArray = vp.XData.AsArray();
            int i = -1;
            foreach (TypedValue tv in xArray)
            {
                i++;
                try
                {
                    if ((string)tv.Value == "AeccPlanProd50ViewportType")
                    {
                        vptype = (short)xArray[i + 1].Value;
                        break;
                    }
                }
                catch { }
            }
            return vptype;
        }
Jeff_M, also a frequent Swamper
EESignature
Message 3 of 9
JanardFugro
in reply to: anhtrung

JanardFugro
Contributor
Contributor

Hi, Is there some cords to get these viewport types by autolisp ?  

        /// 0 = undefined,
        /// 1 = Plan,
        /// 2 = Profile,
        /// 3 = Section
0 Likes

Hi, Is there some cords to get these viewport types by autolisp ?  

        /// 0 = undefined,
        /// 1 = Plan,
        /// 2 = Profile,
        /// 3 = Section
Message 4 of 9
JanardFugro
in reply to: anhtrung

JanardFugro
Contributor
Contributor

Sorry, I mean Is there some codes to get these viewport types by autolisp ? 

0 Likes

Sorry, I mean Is there some codes to get these viewport types by autolisp ? 

Message 5 of 9
BlackBox_
in reply to: JanardFugro

BlackBox_
Advisor
Advisor

@JanardFugro wrote:

Sorry, I mean Is there some codes to get these viewport types by autolisp ? 


(defun _GetViewportType	(vpEname / vpType)
  (cond
    ((=	1
	(setq vpType
	       (cdr
		 (cadr
		   (cadr (assoc	-3
				(entget vpEname '("AeccPlanProd50ViewportType"))
			 )
		   )
		 )
	       )
	)
     )
     "Plan"
    )
    ((= 2 vpType) "Profile")
    ((= 3 vpType) "Section")
    (T "Undefined")
  )
)


"How we think determines what we do, and what we do determines what we get."

0 Likes


@JanardFugro wrote:

Sorry, I mean Is there some codes to get these viewport types by autolisp ? 


(defun _GetViewportType	(vpEname / vpType)
  (cond
    ((=	1
	(setq vpType
	       (cdr
		 (cadr
		   (cadr (assoc	-3
				(entget vpEname '("AeccPlanProd50ViewportType"))
			 )
		   )
		 )
	       )
	)
     )
     "Plan"
    )
    ((= 2 vpType) "Profile")
    ((= 3 vpType) "Section")
    (T "Undefined")
  )
)


"How we think determines what we do, and what we do determines what we get."

Message 6 of 9
JanardFugro
in reply to: BlackBox_

JanardFugro
Contributor
Contributor

Hi Blckbox,

 

Thank you for the fast reply. 

I am not that good in autolisp programing, can you please explain with a simple example, how can I call this function in any other autolisp command. I tried by selecting a viewport but not worked.

0 Likes

Hi Blckbox,

 

Thank you for the fast reply. 

I am not that good in autolisp programing, can you please explain with a simple example, how can I call this function in any other autolisp command. I tried by selecting a viewport but not worked.

Message 7 of 9
BlackBox_
in reply to: JanardFugro

BlackBox_
Advisor
Advisor

No problem: 

 

(defun c:ListViewportType (/ ss)
  (if (setq ss (ssget ":S:E" '((0 . "VIEWPORT"))))
    (prompt
      (strcat
	"\nViewport Type is: "
	(_GetViewportType (ssname ss 0))
	" \n"
      )
    )
  )
  (princ)
)


"How we think determines what we do, and what we do determines what we get."

No problem: 

 

(defun c:ListViewportType (/ ss)
  (if (setq ss (ssget ":S:E" '((0 . "VIEWPORT"))))
    (prompt
      (strcat
	"\nViewport Type is: "
	(_GetViewportType (ssname ss 0))
	" \n"
      )
    )
  )
  (princ)
)


"How we think determines what we do, and what we do determines what we get."

Message 8 of 9
JanardFugro
in reply to: BlackBox_

JanardFugro
Contributor
Contributor
Thank you very much BlackBox. It worked well, brilliant work.

Thank you very much BlackBox. It worked well, brilliant work.
Message 9 of 9
BlackBox_
in reply to: JanardFugro

BlackBox_
Advisor
Advisor

@JanardFugro wrote:
Thank you very much BlackBox. It worked well, brilliant work.

 

You're welcome, @JanardFugro :beer:

 

Cheers



"How we think determines what we do, and what we do determines what we get."

0 Likes


@JanardFugro wrote:
Thank you very much BlackBox. It worked well, brilliant work.

 

You're welcome, @JanardFugro :beer:

 

Cheers



"How we think determines what we do, and what we do determines what we get."

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report