Author Topic: Problem with non-uniformly scaled block  (Read 5748 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 343
Problem with non-uniformly scaled block
« on: September 21, 2012, 08:43:51 AM »
Hello to all

with the help of some of you, in the past, I have written this routine to explode a block and save a selection set of the objects it contains.

Code: [Select]
(defun VxExpode (Ent / CurObj CurSet ObjLst)
  (vl-load-com)
  (setq CurSet (ssadd))
  (setq CurObj (vlax-ename->vla-object Ent))
  (setq ObjExp (vla-Explode (vlax-ename->vla-object Ent)))
  (setq ObjLst (vlax-safearray->list (vlax-variant-value ObjExp)))
  (foreach memb ObjLst
    (setq CurSet (ssadd (vlax-vla-object->ename memb) CurSet))
  )
  (entdel ent)
  CurSet
)

Unfortunately in AutoCAD 2011 (and perhaps even other ...) works well with normal blocks, but when he has to explode a block scaled not uniformly issues the following error:

The ActiveX server returned an error: Invalid index

Do you have any idea on how I can get around this problem?

parktaeeun

  • Guest
Re: Problem with non-uniformly scaled block
« Reply #1 on: September 23, 2012, 09:26:57 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun _Ep ( b )
  2.     (if (= "AcDbBlockReference" (vla-get-objectname (vlax-ename->vla-object b)))
  3.         (progn
  4.             (command "_.explode" b)
  5.             (ssget "p")
  6.         )
  7.     )
  8. )
  9.  

Lupo76

  • Bull Frog
  • Posts: 343
Re: Problem with non-uniformly scaled block
« Reply #2 on: September 23, 2012, 09:51:58 AM »
Unfortunately, in my context I can not use the "command" function  :-(

Lupo76

  • Bull Frog
  • Posts: 343
Re: Problem with non-uniformly scaled block
« Reply #3 on: September 18, 2013, 03:12:00 AM »
Unfortunately, in my context I can not use the "command" function  :-(

Hello to all,
I am writing again much later.
Does anyone know how to fix this?
Is there any alternative?
We accept all ideas.

Thanks in advance

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Problem with non-uniformly scaled block
« Reply #4 on: September 18, 2013, 04:58:10 AM »
Does the block contain any 3S Solids ?  AFAIK, you still cannot explode unequal blocks that contain solids.  -David
R12 Dos - A2K

Lupo76

  • Bull Frog
  • Posts: 343
Re: Problem with non-uniformly scaled block
« Reply #5 on: September 18, 2013, 05:11:38 AM »
No
are normal blocks (only lines and texts).
The command EXPLODE in AutoCAD is capable of exploding these blocks non-uniformly scaled without problems.

Unfortunately I need to do this from code without using the lisp works "command"

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Problem with non-uniformly scaled block
« Reply #6 on: September 18, 2013, 05:30:40 AM »
Unfortunately, in my context I can not use the "command" function  :-(

Someone has to ask .. Why can't you use the "command" function ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Problem with non-uniformly scaled block
« Reply #7 on: September 18, 2013, 05:52:01 AM »
Unfortunately, in my context I can not use the "command" function  :-(

Someone has to ask .. Why can't you use the "command" function ?

The application is very complex and the use of the function command within a reactor crashes

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Problem with non-uniformly scaled block
« Reply #8 on: September 25, 2013, 03:57:37 AM »
What may work:
Instead of processing entities inside the reactor event, the reactor event only collects the entities in a (global) list.
Next...
Code: [Select]
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(MyPostProcessFunction) ")is used to trigger a function that does the actual processing.
Inside (MyPostProcessFunction) you can then use the EXPLODE command.

This was once advised to me by Torsten Moses from Bricsys. But in a different context, (vla-explode) works with non-uniformly scaled blocks in BricsCAD.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Problem with non-uniformly scaled block
« Reply #9 on: September 26, 2013, 06:30:31 AM »
What may work:
Instead of processing entities inside the reactor event, the reactor event only collects the entities in a (global) list.
Next...
Code: [Select]
(vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "(MyPostProcessFunction) ")is used to trigger a function that does the actual processing.
Inside (MyPostProcessFunction) you can then use the EXPLODE command.

This was once advised to me by Torsten Moses from Bricsys. But in a different context, (vla-explode) works with non-uniformly scaled blocks in BricsCAD.
Hello Roy,
thanks for your response.

I hope not too much to ask ...
Could you clarify to me how to use your code inside the mine?

Code: [Select]
(defun VxExpode (Ent / CurObj CurSet ObjLst)
  (vl-load-com)
  (setq CurSet (ssadd))
  (setq CurObj (vlax-ename->vla-object Ent))
  (setq ObjExp (vla-Explode (vlax-ename->vla-object Ent)))
  (setq ObjLst (vlax-safearray->list (vlax-variant-value ObjExp)))
  (foreach memb ObjLst
    (setq CurSet (ssadd (vlax-vla-object->ename memb) CurSet))
  )
  (entdel ent)
  CurSet
)

In addition to explode a block not uniform I have the need to insert within a group of selection all objects contained within the block:
Code: [Select]
(setq oggblock (VxExpode ent))

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Problem with non-uniformly scaled block
« Reply #10 on: September 26, 2013, 08:38:07 AM »
I am afraid you have misunderstood my previous post. The proposed solution is not a case of simply changing a single function. It requires a revision of your reactor events. Which can be a daunting task if your application is already finished and everything else is working just fine...

I am attaching an example:

Code: [Select]
;;; MyApp is a dummy reactor based application that is designed to
;;; demonstrate the use a 'postprocess'. It is not intended as a
;;; finished product.

;;; Author  : Roy Klein Gebbinck
;;; Made for: http://www.theswamp.org/index.php?topic=42826.0

;;; Note: This code was only tested on BricsCAD 13.2.10.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Problem with non-uniformly scaled block
« Reply #11 on: September 26, 2013, 09:34:25 AM »
Unfortunately, it is now impossible to change the structure of the application.
As I said this is a very complicated, tens of thousands of lines of code.

matthewj

  • Newt
  • Posts: 42
  • Vanilla
Re: Problem with non-uniformly scaled block
« Reply #12 on: September 30, 2013, 07:09:03 PM »
Will the VL-CMDF function work instead?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Problem with non-uniformly scaled block
« Reply #13 on: September 30, 2013, 10:41:48 PM »
Perhaps this will work.
Get the insert point and scale of the insert
Scale insert back to 1,1,1
then explode insert
Scale the new objects using the previous insert scales & insert point.

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.

Lupo76

  • Bull Frog
  • Posts: 343
Re: Problem with non-uniformly scaled block
« Reply #14 on: October 04, 2013, 04:57:24 AM »
Unfortunately I was not able to correct function, to the explosion of the blocks is not uniform.

However I solved it by making sure you do not have the need to explode these objects.

Thank you all the same for asking.