Author Topic: 3d array code error  (Read 4034 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
3d array code error
« on: December 21, 2009, 11:27:08 AM »
hi
friend

always thank you for good answer
i made short lisp
but there is problem
can you check pls ?


( defun c:test(   /  )
      
   (setq ss (ssget ))
   
   
   (setq per (getint "\number :"))
   (setq  newss (ssadd))
   (setq index 0)
   (repeat (sslength ss)
             (setq ent1 (ssname ss index))
              (command "3darray" ent1 "" "r"  1 1  per   500  "" )
      
          
              (setq index (+ index 1 ))
   )
   
   )
   

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: 3d array code error
« Reply #1 on: December 21, 2009, 12:04:16 PM »
It's a Lisp routine, so you can't call it with command.

This is janky, but it will work...

Code: [Select]
(defun c:Test (/ num)
  (and (setq ss (ssget "_:L"))
       (setq num (getint "\nNumber: "))
       (vla-sendcommand
         (vla-get-activedocument (vlax-get-acad-object))
         (strcat "(r-array) 1 1 "
                 (vl-princ-to-string num)
                 " 500 "
         ) ;_ strcat
       ) ;_ vla-sendcommand
  ) ;_ and
  (princ)
) ;_ defun

You might want to add a (load "3darray.lsp" nil)
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: 3d array code error
« Reply #2 on: December 21, 2009, 12:20:54 PM »
It's a Lisp routine, so you can't call it with command.

This is janky, but it will work...

Code: [Select]
(defun c:Test (/ num)
  (and (setq ss (ssget "_:L"))
       (setq num (getint "\nNumber: "))
       (vla-sendcommand
         (vla-get-activedocument (vlax-get-acad-object))
         (strcat "(r-array) 1 1 "
                 (vl-princ-to-string num)
                 " 500 "
         ) ;_ strcat
       ) ;_ vla-sendcommand
  ) ;_ and
  (princ)
) ;_ defun

You might want to add a (load "3darray.lsp" nil)

I see you getting hooked on that sendcommand....  :evil:

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: 3d array code error
« Reply #3 on: December 21, 2009, 12:38:18 PM »
Only when it applies to the situation. I've only used it a couple time myself and only when I needed a way to paste a value to the command line for transparent calculations.

This was just a solution to avoid reinventing the wheel.

It's a Lisp routine, so you can't call it with command.

This is janky, but it will work...

Code: [Select]
(defun c:Test (/ num)
  (and (setq ss (ssget "_:L"))
       (setq num (getint "\nNumber: "))
       (vla-sendcommand
         (vla-get-activedocument (vlax-get-acad-object))
         (strcat "(r-array) 1 1 "
                 (vl-princ-to-string num)
                 " 500 "
         ) ;_ strcat
       ) ;_ vla-sendcommand
  ) ;_ and
  (princ)
) ;_ defun

You might want to add a (load "3darray.lsp" nil)

I see you getting hooked on that sendcommand....  :evil:
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

dussla

  • Bull Frog
  • Posts: 297
Re: 3d array code error
« Reply #4 on: December 21, 2009, 12:44:31 PM »
thank you  alanjt

i need more hep ~~

this part 

  (repeat (sslength ss)

(setq ent1 (ssname ss index))
              ( command "extrude"  ent1  100 )
              (setq ent2 (entlast)
              (command "3darray" ent2 "" "r"  1 1  per   500  "" )

 (setq index (+ index 1 ))
   )


i have to make this code
but some difficult to me ~
can you help me again pls

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: 3d array code error
« Reply #5 on: December 21, 2009, 01:06:10 PM »
Code: [Select]
(defun c:Test (/ ss1 num)
  (or *AcadDoc* (setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
  (and (setq ss1 (ssget "_:L"))
       (setq num (getint "\nNumber: "))
       (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss1)))
         (vl-cmdf "_.extrude" x "" 100)
         (setq ss nil)
         (setq ss (ssadd (entlast)))
         (vla-sendcommand
           *AcadDoc*
           (strcat "(r-array) 1 1 "
                   (vl-princ-to-string num)
                   " 500 "
           ) ;_ strcat
         ) ;_ vla-sendcommand
       ) ;_ foreach
  ) ;_ and
  (princ)
) ;_ defun

This is getting worse by the minute.  :|
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

fixo

  • Guest
Re: 3d array code error
« Reply #6 on: December 21, 2009, 01:38:02 PM »
thank you  alanjt

i need more hep ~~

this part 

  (repeat (sslength ss)

(setq ent1 (ssname ss index))
              ( command "extrude"  ent1  100 )
              (setq ent2 (entlast)
              (command "3darray" ent2 "" "r"  1 1  per   500  "" )

 (setq index (+ index 1 ))
   )


i have to make this code
but some difficult to me ~
can you help me again pls

Try this one instead
Guess you want to get a number of newly created object
in 3d array
Code: [Select]
(defun c:test(/ acsp adoc objs obj_list per pfs)
  (setq adoc (vla-get-activedocument
     (vlax-get-acad-object)
     )
      acsp (vla-get-block
     (vla-get-activelayout adoc))
      )
  (setq per (getint "\n   Number of levels: "))
 
  (setq pfs (vla-get-pickfirstselectionset adoc))
  (vlax-invoke-method pfs 'Clear)
  (vla-selectonscreen pfs)

  (vlax-for obj pfs
   (setq objs  (vla-arrayrectangular obj
1 ;number of rows
1 ;number of columns
per;number of levels
0 ;distance between rows
0;distance between columns
500;distance between levels
)
objs (vlax-safearray->list (vlax-variant-value objs))
;; collect objects :
obj_list (append objs obj_list)
;; add parent object :
obj_list (append (list obj) obj_list);<-- comment this if you no need to add a parent object
)
   )
  (alert (strcat "Total objects in all arrays: " (itoa (length obj_list))))
  (princ)
  )
(vl-load-com)

~'J'~

dussla

  • Bull Frog
  • Posts: 297
Re: 3d array code error
« Reply #7 on: December 21, 2009, 02:16:19 PM »
alja    thank you  help
but ther is problem 
can you see attached file ?
that code don't work   well   when i select many objects




fixo :
your code is good also
1.can you add extrude code  pls .
2.  can i use    (setq ss1 (ssget "_:L"))      instead  (setq pfs (vla-get-pickfirstselectionset adoc))    ?

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: 3d array code error
« Reply #8 on: December 21, 2009, 02:17:34 PM »
Well sure, if you want to do it the right way.  :-D
thank you  alanjt

i need more hep ~~

this part 

  (repeat (sslength ss)

(setq ent1 (ssname ss index))
              ( command "extrude"  ent1  100 )
              (setq ent2 (entlast)
              (command "3darray" ent2 "" "r"  1 1  per   500  "" )

 (setq index (+ index 1 ))
   )


i have to make this code
but some difficult to me ~
can you help me again pls

Try this one instead
Guess you want to get a number of newly created object
in 3d array
Code: [Select]
(defun c:test(/ acsp adoc objs obj_list per pfs)
  (setq adoc (vla-get-activedocument
     (vlax-get-acad-object)
     )
      acsp (vla-get-block
     (vla-get-activelayout adoc))
      )
  (setq per (getint "\n   Number of levels: "))
 
  (setq pfs (vla-get-pickfirstselectionset adoc))
  (vlax-invoke-method pfs 'Clear)
  (vla-selectonscreen pfs)

  (vlax-for obj pfs
   (setq objs  (vla-arrayrectangular obj
1 ;number of rows
1 ;number of columns
per;number of levels
0 ;distance between rows
0;distance between columns
500;distance between levels
)
objs (vlax-safearray->list (vlax-variant-value objs))
;; collect objects :
obj_list (append objs obj_list)
;; add parent object :
obj_list (append (list obj) obj_list);<-- comment this if you no need to add a parent object
)
   )
  (alert (strcat "Total objects in all arrays: " (itoa (length obj_list))))
  (princ)
  )
(vl-load-com)

~'J'~
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: 3d array code error
« Reply #9 on: December 21, 2009, 02:18:29 PM »
I figured you would have problems with it, but I didn't have time to dig in to rewriting the entire thing.
It appears Fixo is going in the right direction. :)
alja    thank you  help
but ther is problem 
can you see attached file ?
that code don't work   well   when i select many objects




fixo :
your code is good also
1.can you add extrude code  pls .
2.  can i use    (setq ss1 (ssget "_:L"))      instead  (setq pfs (vla-get-pickfirstselectionset adoc))    ?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: 3d array code error
« Reply #10 on: December 21, 2009, 02:22:54 PM »
Nice method Fixo, but why:

Code: [Select]
  (setq pfs (vla-get-pickfirstselectionset adoc))
  (vlax-invoke-method pfs 'Clear)
  (vla-selectonscreen pfs)

Over:

Code: [Select]
(if (setq ss (ssget "_:L"))
  (vlax-for obj (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))))
  ...


?

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: 3d array code error
« Reply #11 on: December 21, 2009, 02:29:04 PM »
Pants on right leg before left.

Nice method Fixo, but why:

Code: [Select]
  (setq pfs (vla-get-pickfirstselectionset adoc))
  (vlax-invoke-method pfs 'Clear)
  (vla-selectonscreen pfs)

Over:

Code: [Select]
(if (setq ss (ssget "_:L"))
  (vlax-for obj (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))))
  ...


?
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

fixo

  • Guest
Re: 3d array code error
« Reply #12 on: December 21, 2009, 03:00:14 PM »
alja    thank you  help
but ther is problem 
can you see attached file ?
that code don't work   well   when i select many objects




fixo :
your code is good also
1.can you add extrude code  pls .
2.  can i use    (setq ss1 (ssget "_:L"))      instead  (setq pfs (vla-get-pickfirstselectionset adoc))    ?

Will be back in hour or less

~'J'~

fixo

  • Guest
Re: 3d array code error
« Reply #13 on: December 21, 2009, 03:11:28 PM »
alja    thank you  help
but ther is problem 
can you see attached file ?
that code don't work   well   when i select many objects




fixo :
your code is good also
1.can you add extrude code  pls .
2.  can i use    (setq ss1 (ssget "_:L"))      instead  (setq pfs (vla-get-pickfirstselectionset adoc))    ?
Here is quick edition

If you have more questions personally to me -
I will be busy entire next hour

Code: [Select]



(defun c:test(/ acsp adoc en obj objs obj_list per reg solid sset)
  (setq adoc (vla-get-activedocument
     (vlax-get-acad-object)
     )
      acsp (vla-get-block
     (vla-get-activelayout adoc))
      )
  (setq per (getint "\n   Number of levels: "))
 
  (setq sset (ssget "_:L" (list (cons 0 "LWPOLYLINE")(cons 70 1))))
  (while (setq en (ssname sset 0))
  (setq obj (vlax-ename->vla-object en))
  (setq reg (car
  (vlax-invoke acsp 'AddRegion (list obj)
  )
)
)

(setq solid (vla-addextrudedsolid acsp reg 100 0))
   (setq objs  (vla-arrayrectangular solid
1 ;number of rows
1 ;number of columns
per;number of levels
0 ;distance between rows
0;distance between columns
500;distance between levels
)
objs (vlax-safearray->list (vlax-variant-value objs))
;; collect objects :
obj_list (append objs obj_list)
;; add parent object :
obj_list (append (list obj) obj_list);<-- comment this if you no need to add a parent object
)
    (ssdel en sset)
   )
  (alert (strcat "Total objects in all arrays: " (itoa (length obj_list))))
  (princ)
  )
(vl-load-com)

~'J'~

dussla

  • Bull Frog
  • Posts: 297
Re: 3d array code error
« Reply #14 on: December 22, 2009, 09:19:17 AM »
thank you   very very very very much
code is very perpect
always thank you ~~~