Change Layer
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
Change Layer

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
GaryDF
Guest





Posted: Wed Jan 12, 2005 3:17 am    Post subject: Change Layer Reply with quote

How would I use co1 in a routine to change a layer?
I want to change the layer of the line selected to clayer.

(setq co1 (objsel "\n* Select First Line *"))

;;code by Dan <no last name>
;;code taken from Corner Notch routine posted eariler today.
(defun objsel ($prompt / ent obj)
(setq ent (car (entsel $prompt)))
(if (/= ent nil)
(setq obj (vlax-ename->vla-object ent))
(princ "\n* No Object Selected *"))
obj ;returns result for use in calling program
)


Gary

Back to top
T.Willey
Guest





Posted: Wed Jan 12, 2005 3:27 am    Post subject: Re: Change Layer Reply with quote

(vla-put-Layer Obj (getvar "clayer")) ??

Tim
Back to top
Jason Piercey
Guest





Posted: Wed Jan 12, 2005 3:27 am    Post subject: Re: Change Layer Reply with quote

(vla-put-layer <vla-object> "MyLayerName")

--
Autodesk Discussion Group Facilitator



"GaryDF" <arch_program@hotmail.com> wrote in message
news:41e4512e$1_2@newsprd01...
Quote:
How would I use co1 in a routine to change a layer?
I want to change the layer of the line selected to clayer.

(setq co1 (objsel "\n* Select First Line *"))

;;code by Dan <no last name
;;code taken from Corner Notch routine posted eariler today.
(defun objsel ($prompt / ent obj)
(setq ent (car (entsel $prompt)))
(if (/= ent nil)
(setq obj (vlax-ename->vla-object ent))
(princ "\n* No Object Selected *"))
obj ;returns result for use in calling program
)


Gary



Back to top
GaryDF
Guest





Posted: Wed Jan 12, 2005 4:44 am    Post subject: Re: Change Layer Reply with quote

Thanks for the reply...
Here is my modified code.
The layer does not stay changed...what am I missing?

;;;by Dan <no last name>
;;;ARCH#_DIS global distance
(defun c:CNOTCH (/ mspc xdim pt1 pt2 pt3 pt4 pt5 ang ang3 ang4 int co1 co2 nlin1
nlin2 nco1
nco2)
(vl-load-com)
(command "undo" "mark")
(setq mspc (vla-get-ModelSpace
(vla-get-activeDocument (vlax-get-object "Autocad.application"))))
(cond
((= ARCH#_DIS nil)
(setq xdim (getreal "\n* Enter Dimension For Notch: "))
(setq ARCH#_DIS xdim)
)
((/= ARCH#_DIS nil)
(setq xdim (getreal (strcat "\n* Enter Dimension For Notch <" (rtos
ARCH#_DIS 4 6) ">: ")))
(if (= xdim nil)(setq xdim ARCH#_DIS))
)
)
(setq co1 (objsel "\n* Select First Line *"))
(setq co2 (objsel "\n* Select Second Line *"))
(if (and (= (vla-get-ObjectName co1) "AcDbLine")
(= (vla-get-ObjectName co2) "AcDbLine"))
(progn (setq int (vlax-invoke co1 'IntersectWith co2 acExtendBoth))
(reline co1 int xdim)
(setq pt3 pt1)
(setq ang3 ang)
(vlax-invoke co1 'Erase)
(setq nco1 (vla-AddLine mspc (vlax-3d-point pt1) (vlax-3d-point pt2)))
(reline co2 int xdim)
(setq pt4 pt1)
(setq ang4 ang)
(vlax-invoke co2 'Erase)
(setq nco2 (vla-AddLine mspc (vlax-3d-point pt1) (vlax-3d-point pt2)))
(setq pt5 (polar pt4 ang3 xdim))
(setq nlin1 (vla-AddLine mspc (vlax-3d-point pt4) (vlax-3d-point
pt5)))
(setq nlin2 (vla-AddLine mspc (vlax-3d-point pt3) (vlax-3d-point
pt5))))
(princ "\n* Object Must Be A Line *"))
(princ))
;;;
(defun reline (lin int xdim / stpt endpt)
(setq stpt (vlax-get lin 'StartPoint))
(setq endpt (vlax-get lin 'EndPoint))
(if (> (distance int stpt) (distance int endpt))
(progn (setq ang (angle endpt stpt))
(setq pt1 (polar int ang xdim))
(setq pt2 stpt))
(progn (setq ang (angle stpt endpt))
(setq pt1 (polar int ang xdim))
(setq pt2 endpt))))
;;;The following gets and returns a selected object in activex format
;;;usage = (setq obj (objsel "\n* Select Object *"))
(defun objsel ($prompt / ent obj)
(setq ent (car (entsel $prompt)))
(if (/= ent nil)
(progn
(setq obj (vlax-ename->vla-object ent))
;(if ARCH#NLAY (vla-put-Layer obj ARCH#NLAY))
(vla-put-Layer obj (getvar "clayer")) ;added here
)
(princ "\n* No Object Selected *"))
obj ;returns result for use in calling program
)




"T.Willey" <nospam@address.withheld> wrote in message
news:25103568.1105482454150.JavaMail.jive@jiveforum2.autodesk.com...
Quote:
(vla-put-Layer Obj (getvar "clayer")) ??

Tim
Back to top
GaryDF
Guest





Posted: Wed Jan 12, 2005 4:50 am    Post subject: Re: Change Layer Reply with quote

Thanks...see my reply to Tim.

"Jason Piercey" <Jason AT atreng DOT com> wrote in message
news:41e452b3_2@newsprd01...
Quote:
(vla-put-layer <vla-object> "MyLayerName")

--
Autodesk Discussion Group Facilitator



"GaryDF" <arch_program@hotmail.com> wrote in message
news:41e4512e$1_2@newsprd01...
How would I use co1 in a routine to change a layer?
I want to change the layer of the line selected to clayer.

(setq co1 (objsel "\n* Select First Line *"))

;;code by Dan <no last name
;;code taken from Corner Notch routine posted eariler today.
(defun objsel ($prompt / ent obj)
(setq ent (car (entsel $prompt)))
(if (/= ent nil)
(setq obj (vlax-ename->vla-object ent))
(princ "\n* No Object Selected *"))
obj ;returns result for use in calling program
)


Gary



Back to top
Jeff Mishler
Guest





Posted: Wed Jan 12, 2005 5:02 am    Post subject: Re: Change Layer Reply with quote

Gary,
You are "Erasing" the objects that you changed the layer of......

I'm not following what you are trying to end up with here.

--
Jeff
check out www.cadvault.com
"GaryDF" <arch_program@hotmail.com> wrote in message
news:41e46588$1_1@newsprd01...
Quote:
Thanks for the reply...
Here is my modified code.
The layer does not stay changed...what am I missing?
Back to top
GaryDF
Guest





Posted: Wed Jan 12, 2005 5:24 am    Post subject: Re: Change Layer Reply with quote

Thats what I thought it was doing....
I want the lines selected and the corner notched lines added to be
changed to the clayer.

This vla stuff has be confused.

I have a work around, but would like to see how to modify the existing
code.

Thanks for the help.

Gary

"Jeff Mishler" <jeff_m@cadvault.com> wrote in message
news:41e46926$1_1@newsprd01...
Quote:
Gary,
You are "Erasing" the objects that you changed the layer of......

I'm not following what you are trying to end up with here.

--
Jeff
check out www.cadvault.com
"GaryDF" <arch_program@hotmail.com> wrote in message
news:41e46588$1_1@newsprd01...
Thanks for the reply...
Here is my modified code.
The layer does not stay changed...what am I missing?

Back to top
GaryDF
Guest





Posted: Wed Jan 12, 2005 6:07 am    Post subject: Re: Change Layer Reply with quote

This is what I was trying to do...your tips helped.
Here is the revised code:

Code:

;;;Dann
;;;ARCH#_DIS global distance var
;;;ARCH#NLAY global new layer var
;;;
(defun C:NOTCH  (/ mspc xdim pt1 pt2 pt3 pt4 pt5 ang ang3 ang4 int co1 co2 nlin1
nlin2 nco1 nco2)
  (vl-load-com)
  (command "undo" "mark")
  (setq mspc (vla-get-ModelSpace
               (vla-get-activeDocument (vlax-get-object "Autocad.application"))))
  (cond
    ((= ARCH#_DIS nil)
      (setq xdim (getreal "\n* Enter Dimension For Notch: "))
      (setq ARCH#_DIS xdim)
    )
    ((/= ARCH#_DIS nil)
      (setq xdim (getreal (strcat "\n* Enter Dimension For Notch <" (rtos
ARCH#_DIS 4 6) ">: ")))
      (if (= xdim nil)(setq xdim ARCH#_DIS))
    )
  )
  (setq co1 (objsel "\n* Select First Line *"))
  (setq co2 (objsel "\n* Select Second Line *"))
  (if (and (= (vla-get-ObjectName co1) "AcDbLine")
           (= (vla-get-ObjectName co2) "AcDbLine"))
    (progn (setq int (vlax-invoke co1 'IntersectWith co2 acExtendBoth))
           (reline co1 int xdim)
           (setq pt3 pt1)
           (setq ang3 ang)
           (vlax-invoke co1 'Erase)
           (setq nco1 (vla-AddLine mspc (vlax-3d-point pt1) (vlax-3d-point pt2)))
           (if ARCH#NLAY (vla-put-Layer nco1 ARCH#NLAY)) ;<---new
           (reline co2 int xdim)
           (setq pt4 pt1)
           (setq ang4 ang)
           (vlax-invoke co2 'Erase)
           (setq nco2 (vla-AddLine mspc (vlax-3d-point pt1) (vlax-3d-point pt2)))
           (if ARCH#NLAY (vla-put-Layer nco2 ARCH#NLAY)) ;<---new
           (setq pt5 (polar pt4 ang3 xdim))
           (setq nlin1 (vla-AddLine mspc (vlax-3d-point pt4) (vlax-3d-point
pt5)))
           (if ARCH#NLAY (vla-put-Layer nlin1 ARCH#NLAY)) ;<---new
           (setq nlin2 (vla-AddLine mspc (vlax-3d-point pt3) (vlax-3d-point
pt5)))
           (if ARCH#NLAY (vla-put-Layer nlin2 ARCH#NLAY)) ;<---new
           )
    (princ "\n* Object Must Be A Line *"))
  (princ))
;;;
(defun reline  (lin int xdim / stpt endpt)
  (setq stpt (vlax-get lin 'StartPoint))
  (setq endpt (vlax-get lin 'EndPoint))
  (if (> (distance int stpt) (distance int endpt))
    (progn (setq ang (angle endpt stpt))
           (setq pt1 (polar int ang xdim))
           (setq pt2 stpt))
    (progn (setq ang (angle stpt endpt))
           (setq pt1 (polar int ang xdim))
           (setq pt2 endpt))))
;;;The following gets and returns a selected object in activex format
;;;usage = (setq obj (objsel "\n* Select Object *"))
(defun objsel  ($prompt / ent obj)
  (setq ent (car (entsel $prompt)))
  (if (/= ent nil)
    (setq obj (vlax-ename->vla-object ent))
    (princ "\n* No Object Selected *"))
  obj ;returns result for use in calling program
  )


Gary


"GaryDF" <arch_program@hotmail.com> wrote in message
news:41e46ede$1_3@newsprd01...
Quote:
Thats what I thought it was doing....
I want the lines selected and the corner notched lines added to be
changed to the clayer.

This vla stuff has be confused.

I have a work around, but would like to see how to modify the existing
code.

Thanks for the help.

Gary

"Jeff Mishler" <jeff_m@cadvault.com> wrote in message
news:41e46926$1_1@newsprd01...
Gary,
You are "Erasing" the objects that you changed the layer of......

I'm not following what you are trying to end up with here.

--
Jeff
check out www.cadvault.com
"GaryDF" <arch_program@hotmail.com> wrote in message
news:41e46588$1_1@newsprd01...
Thanks for the reply...
Here is my modified code.
The layer does not stay changed...what am I missing?




Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB