Author Topic: backward blocks  (Read 4175 times)

0 Members and 1 Guest are viewing this topic.

Ron Heigh

  • Guest
backward blocks
« on: July 02, 2004, 11:14:57 AM »
Is it possible to tell certain block not to be backward when the get mirrored?
Sort of like applying the mirrtext variable to text and blocks.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
backward blocks
« Reply #1 on: July 02, 2004, 01:51:06 PM »
Not that I know of, but it sounds like a neat reactor... kindof like my program that monitors block insertions and puts them on the correct layer automatically.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
backward blocks
« Reply #2 on: July 02, 2004, 03:15:23 PM »
Here is a nice utility that will draw a circle at the insertion point of any mirrored block.

Code: [Select]

(defun c:Mblk ();(/ cmd blks count index b1 b2 b3 b4 c1)
  (setq cmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq savlay (getvar "CLAYER"))
  (setvar "clayer" "0")
  (setq savosmode (getvar "OSMODE"))
  (setvar "osmode" 0)
  (setq blks (ssget "x" '((0 . "INSERT"))))
  (setq count (sslength blks))
  (setq count (sslength blks))
  (setq index 0)
  (repeat count
    (setq b1 (entget (ssname blks index)))
    (setq b2 (cdr(assoc 41 b1)));X
    (setq xb2 (cdr(assoc 42 b1)));Y
    (setq xb3 (cdr(assoc 43 b1)));Z
    (setq b3 (rtos b2 2 0));X
    (setq b4 (substr b3 1 1));X
    (if (/= b2 1.0);check for X
      (progn
 (setq c1 (cdr(assoc 10 b1)))
 (command "circle" c1 50)
      );end progn
    );end if
    (if (/= xb2 1.0);check for Y
      (progn
 (setq c1 (cdr(assoc 10 b1)))
 (command "circle" c1 50)
      );end progn
    ); end if
    (if (/= xb3 1.0);check for Z
      (progn
 (setq c1 (cdr(assoc 10 b1)))
 (command "circle" c1 50)
      );end progn
    );end if
    (setq index (+ index 1))
    );end repeat
  (setvar "CMDECHO" cmd)
  (setvar "CLAYER" savlay)
  (setvar "OSMODE" savosmode)
  (princ)
)
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

V-Man

  • Bull Frog
  • Posts: 343
  • I exist therefore I am! Finally Retired!
backward blocks
« Reply #3 on: July 02, 2004, 03:22:30 PM »
I probably should elaborate on this a little. This routine will draw a circle at the insertion point of any block that has it's "X" "Y" "Z" values other than 1
AutoCAD 9 - 2023, AutoCADMap 2008 - 2010, Revit 2012 - 2022, Autocad Civil 3D 2023

Ron Heigh

  • Guest
backward blocks
« Reply #4 on: July 03, 2004, 10:45:12 AM »
I agree that a reactor of some sort would be required.
It would be activated when the mirror command is called.
I need to make it so that if a weld or North symbol gets mirrored, they don't get flipped.
I've not very good at reactors though.

SpeedCAD

  • Guest
backward blocks
« Reply #5 on: July 03, 2004, 12:42:09 PM »
Hi...

Change the scale X to 1, or Y to 1. With command reactor you can make...

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
backward blocks
« Reply #6 on: July 04, 2004, 12:34:14 AM »
In VBA utilize the EndCommand reactor you should be able to accomplish what you need....

You will need to tweak this to make sure you grab the objecs created with a mirror IF the originals are not deleted. This could probably be handled with a BeginCommand reactor and a global value to hold the new objects created with a mirror command.
Code: [Select]

Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
 Dim BlockSSet As AcadSelectionSet
 Dim CurrBlock As AcadBlockReference
 
 If (UCase(CommandName) = "MIRROR") Or UCase(CommandName = "_MIRROR") Then
 Set BlockSSet = ThisDrawing.SelectionSets.Add("nomirrorblocks")
 BlockSSet.Select acSelectionSetPrevious
 On Error Resume Next
 For Each CurrBlock In BlockSSet
  Select Case UCase(CurrBlock.Name)
   Case "WELD1"
    CurrBlock.XScaleFactor = Abs(CurrBlock.XScaleFactor)
    CurrBlock.YScaleFactor = Abs(CurrBlock.YScaleFactor)
    CurrBlock.ZScaleFactor = Abs(CurrBlock.ZScaleFactor)
   Case "WELD2"
    CurrBlock.XScaleFactor = Abs(CurrBlock.XScaleFactor)
    CurrBlock.YScaleFactor = Abs(CurrBlock.YScaleFactor)
    CurrBlock.ZScaleFactor = Abs(CurrBlock.ZScaleFactor)
   Case "NORTH"
    CurrBlock.XScaleFactor = Abs(CurrBlock.XScaleFactor)
    CurrBlock.YScaleFactor = Abs(CurrBlock.YScaleFactor)
    CurrBlock.ZScaleFactor = Abs(CurrBlock.ZScaleFactor)
  End Select
 Next CurrBlock
 BlockSSet.Delete
 End If
End Sub
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Ron Heigh

  • Guest
backward blocks
« Reply #7 on: July 05, 2004, 01:30:52 PM »
Keith, I've begon the journey, just need some more road maps.
The text is backward on a mirror/delete but the reactor is firing as needed. (because of "MIRRTEXT")
The reactor doesn't fire on a mirror/ w/out delete.

TODO:
-capture the mirrored item when not deleting the original
-save and set "MIRRTEXT" to 1 before the reactor
-restore "MIRRTEXT" to original value after reactor

Where should I search for these kinds of problems?
What should I use for my help file?

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
backward blocks
« Reply #8 on: July 05, 2004, 01:45:32 PM »
Quote from: Ron Heigh
Keith, I've begon the journey, just need some more road maps.
The text is backward on a mirror/delete but the reactor is firing as needed. (because of "MIRRTEXT")
The reactor doesn't fire on a mirror/ w/out delete.

TODO:
-capture the mirrored item when not deleting the original
-save and set "MIRRTEXT" to 1 before the reactor
-restore "MIRRTEXT" to original value after reactor

Where should I search for these kinds of problems?
What should I use for my help file?


Ok, I need to find out something .....
Do these blocks contain attributes? If they do, then the mirroring of the blocks (with mirrtext on) will produce acceptable results except the block will be mirrored,  the text should not be, but when mirroring with delete, the blocks mirrored are reset to a positive scale factor ... that is the abs function returning the absolute value of the scale factor and reapplying it. However this does not qualify as a mirror and as such mirrtext does not apply, AND the resulting text WILL be backward.
To account for this, you will need to obtain the attributes of those blocks and change each one of them to not be displayed mirrored. Plain text embedded in blocks will always be shown in the defined fashion, in relation to the rotation and scale of the block, and as such is unaffected by mirrtext.

As I posted before, what you can do is create a "BeginCommand" reactor that will grab the last entity in the drawing, then using it as the base and all objects created after this one are new, and as such should be gathered into the selection set. This selection set can then be acted upon by the EndCommand reactor when the mirror command ends.

As far as the help file, I am not following your request here, but just in case I misunderstood I will give you two options ....

For VB(a) help simply use the help files associated with the VBAIDE interface and the MS VBA help files (accessable from the help menu in the VBAIDE) Also look at the object reference window and you will get a better understanding of objects and their associated proerties and methods.

Now if you were looking for a help compiler to build a help file for your application, there are a few out there that are free and I know Hendie has used one, you might see if he can point you in the right direction.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Ron Heigh

  • Guest
backward blocks
« Reply #9 on: July 05, 2004, 01:48:20 PM »
Thanks,  I'll get back once I've had some time to process.....

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
backward blocks
« Reply #10 on: July 05, 2004, 03:51:00 PM »
How about hijacking the mirror command?
Collect the objects to be mirrored in a selection set.
remove the blocks you want un mirrored to a 2nd selection set.
Mirror selection set 1
Then copy & past the objects from selection set 2 to the mirror position.

Would that work?
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.

Ron Heigh

  • Guest
backward blocks
« Reply #11 on: July 05, 2004, 04:16:22 PM »
I've actually decided to take this opportunity to learn reactors.
I've figured out how to do it with lisp, now I just need to get my reactors working.