Author Topic: copybase code porblem  (Read 2797 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
copybase code porblem
« on: October 08, 2008, 06:19:31 AM »
it is copy base  ->  paste -> drilll code
but that did not work
what is problem

(defun  c:CB2( / pt1 p1 p2  la2 lad copyb )
   (setvar "osmode" 35 )
   (setq lad (getvar "clayer"))
   (setq pt1 (getpoint "\n point: "))
   (setvar "osmode" 0 )
   
   (princ)
   (setq ent (entsel "\nSelect object for layer filter."))
    (setq lay (cdr(assoc 8 (entget (car ent)))))
   (setq p1 (getpoint "\nFirst corner :"))
    (setq p2 (getcorner p1 "\nSecond corner :")) 
   (setq copyb (ssget  "w" p1 p2  (list '(0 . "*polyline,circle,ellipse,region")(cons 8 lay))))
   
   (cadr(sssetfirst nil copyb))
   (command "COPYBASE" pt1 copyb "")
    (setvar "clayer" lad)

(setvar "osmode" 35 )

)




« Last Edit: May 10, 2012, 04:13:07 AM by dussla »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: copybase code porblem
« Reply #1 on: October 08, 2008, 09:04:25 AM »
Your object is a 3Dsolid which is not in your ssget list.
Try this:
Code: [Select]
(defun c:CB2 (/ pt1 p1 p2 lay lad copyb)
  (setvar "osmode" 35)
  (setq lad (getvar "clayer"))
  (and
    (setq pt1 (getpoint "\nPick Base Point: "))
    (setq ent (entsel "\nSelect object for layer filter."))
    (setq lay (cdr (assoc 8 (entget (car ent)))))
    (setvar "osmode" 0)
    (setq p1 (getpoint "\nSelection Set: First corner :"))
    (setq p2 (getcorner p1 "\nSecond corner :"))
    (setq copyb (ssget "w" p1 p2
                       (list '(0 . "*polyline,circle,ellipse,region,3dsolid") (cons 8 lay))))
    (cadr (sssetfirst nil copyb))
    (command "COPYBASE" "_non" pt1 copyb "")
  )
  (setvar "clayer" lad)
  (setvar "osmode" 35)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Andrea

  • Water Moccasin
  • Posts: 2372
Re: copybase code porblem
« Reply #2 on: October 08, 2008, 09:17:57 AM »
don't forget to underscore it.  :wink:
Your object is a 3Dsolid which is not in your ssget list.
Try this:
Code: [Select]
(defun c:CB2 (/ pt1 p1 p2 lay lad copyb)
...(setq copyb (ssget "[color=red]_[/color]w" p1 p2.....
    (command "[color=red]._[/color]COPYBASE" "_non" pt1 .....
)
Keep smile...

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: copybase code porblem
« Reply #3 on: October 08, 2008, 09:50:28 AM »
And the other routine.
A quick hack to get you going. 8-)
Code: [Select]
(defun c:dr2 (/ la lad ss newss newobj cut1 cut2 cut3 nl)
  (vl-load-com)
  (setq lad (getvar "clayer"))
  (setq oldec (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)
  (setq la "_WALLDRILL")
  (setq la2 "__im")
  (setq nl "_wall")
  (command "-Layer" "m" la "c" "RED" la "s" la "")
  (command "-Layer" "m" nl "c" "YELLOW" nl "s" nl "")

  (if
    (and
      (setq cut1 (entsel "\nSelect cutting object."))
      (null (command "extrude" cut1 "" 850 ""))
      (setq cut2 (entlast))
      (setvar "osmode" 35)
      (print "Move cutting object into place.")
      (null (command "move" cut2 "" pause pause))
      (setq cut3 (entsel "\nSelect object to cut."))
      (null (command "subtract" cut3 "" cut2 ""))
    )
     (progn
       (command "change" cut3 "" "p" "la" NL "")
       (command "draworder" cut3 "" "b")
       (command "regen")
     )
  )
  (setvar "clayer" lad)
  (setvar "osmode" 35)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dussla

  • Bull Frog
  • Posts: 297
Re: copybase code porblem
« Reply #4 on: October 08, 2008, 09:52:47 AM »
cb2  is good

 after select object  cb2  .then , i  dr2 command  on solid
but  dr2  didn't work
what is problem



dussla

  • Bull Frog
  • Posts: 297
Re: copybase code porblem
« Reply #5 on: October 08, 2008, 10:05:38 AM »
wow quick ~
i test  .
cab , but that dr2 is some problem

i use cusom ucs for 3d modeling 
that is useful  code

i need multiple object copybase -> paste -> subtract ( big - small object)
sorry , my many ask

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: copybase code porblem
« Reply #6 on: October 08, 2008, 10:46:58 AM »
This code is not the finished routine, but a next step in the process. :-)
Code: [Select]
(defun c:dr2 (/ la lad ss newss newobj cut1 ss2 cut3 nl)
  (setq lad (getvar "clayer"))
  (setq oldec (getvar "cmdecho"))
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)
  (setq la "_WALLDRILL")
  (setq la2 "__im")
  (setq nl "_wall")
  (command "-Layer" "m" nl "c" "YELLOW" nl "s" nl "")
  (command "-Layer" "m" la "c" "RED" la "s" la "")

  (if
    (and
      (princ "\nSelect cutting object(s).")
      (setq ss (ssget '((0 . "*polyline,circle,ellipse"))))
      (setq ss2 (ssadd))
      (setq i -1)
      (while (setq ename (ssname ss (setq i (1+ i))))
        (command "extrude" ename "" 850 "")
        (ssadd (entlast) ss2)
      )
      (setvar "osmode" 35)
      (print "Move cutting object into place.")
      (null (command "move" ss2 "" pause pause))
      (setq cut3 (entsel "\nSelect object to cut."))
      (null (command "subtract" cut3 "" ss2 ""))
    )
     (progn
       (command "change" cut3 "" "p" "la" NL "")
       (command "draworder" cut3 "" "b")
       (command "regen")
     )
  )
  (setvar "clayer" lad)
  (setvar "osmode" 35)
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.