Author Topic: Problem with lisp DBMAN - Dynamically change the orientation and block scale  (Read 2769 times)

0 Members and 1 Guest are viewing this topic.

nini007

  • Newt
  • Posts: 58
Hello,

I ask for the help of the forum :-)
I found a lisp of Andrea Andreetti DuctiSoft company (http://www.ductisoft.com) that would serve me very well, it is especially the rotation option that interests me.  :wink:
Unfortunately he has one or two small bug. :-o
1. I have attributes in a block and when I rotate with the DBMAN command the text does not rotate with the block?
2. If we use the Moved option, it moves the blocks well but not the attributes?
3. Does the Copy option crash my AutoCAD 2018?
4. The Scale option I did not understand how it works?

Would someone have a solution? :idea:

thank you in advance
Best regards

Augusto

  • Newt
  • Posts: 75
You will have to enter the "attsync" command inside the function "UpdateBlocks "

Code: [Select]
(defun UpdateBlocks (cons1 value)


  (setq NBpoint (cadr (assoc Bselec INSlocation)))
  (repeat (1+ #block)
    (setq SSblock (ssname allBlock (setq val (1+ val))))
    (setq entBdata (entget SSblock))
    (setq ent10 (cdr (assoc 10 entBdata))) ;insertion point
    (setq itemangle (cdr (assoc 50 entBdata))) ;Block Angle

    (setq cursorpoint2 cursorpoint)
    (setq cursorangle2 (angle NBpoint cursorpoint))   
    (setq cursordistance2 (distance NBpoint cursorpoint)) 
   
    (if (eq ToDo "MOVE")
      (progn
        (setq Npoint2 (polar (cadr (assoc SSblock INSpoints)) cursorangle2 cursordistance2))
       
        (grdraw (cadr (assoc SSblock INSpoints))
                Npoint2
                4
                1
             )
                       
(setq cursorangle2 (angle (cadr (assoc SSblock INSpoints)) Npoint2))
(setq entBdata (subst (cons cons1 Npoint2)
      (assoc cons1 entBdata)
      entBdata
       )
)
(setq insPblock (cdr (assoc 10 (entget (car (nth #iblock INSpoints))))))
       
      )
    )



    (if (eq todo "ROTATION")
      (progn (grdraw ent10
                     (polar ent10 (angle NBpoint cursorpoint) cursordistance)
                     4
                     1
             )

(setq value (angle  ent10 (polar ent10 (angle NBpoint cursorpoint) cursordistance)))
       
             (if (eq rotrequest "R");Relatif
               (progn
               (Setq  IBangle (+ value (cadr (assoc SSblock ANGpoints))))
               (Setq  itemAngle (cdr (assoc cons1 entbdata)))
               )
             )
             (if (eq rotrequest "A");Absolu
               (progn
               (setq itemangle value)
               (setq IBangle value)
               )
             )
             (if (eq rotrequest "V");Valeur
               (progn
               (setq itemangle value)
               (setq IBangle value)
               )
             )
             (setq entbdata (subst (cons cons1 IBangle)
                                   (assoc cons1 entbdata)
                                   entbdata
                            )
             )
      )
    )



    (if (eq ToDo "SCALE")
      (progn
(grdraw ent10
(polar ent10
       cursorangle2
       cursordistance2
)
4
1
)       
        (if (eq rotrequest "R");Relatif
               (progn
               (Setq  itemXscale   (+ value (caadr (assoc SSblock SCALEpoints))))
               (Setq  itemYscale   (+ value (cadadr (assoc SSblock SCALEpoints)))) 
               )
          )
        (if (eq rotrequest "A");Absolu
               (progn
                 (setq itemXscale value)
                 (setq itemYscale value)
               )
          )
        (if (eq rotrequest "V");Valeur
               (progn
                 (setq itemXscale value)
                 (setq itemYscale value)
               )
          )
(setq entBdata (subst (cons 41 itemXscale) (assoc 41 entBdata)  entBdata ))
(setq entBdata (subst (cons 42 itemYscale) (assoc 42 entBdata)  entBdata ))
      ) 
    )


   
    (if (eq ToDo "ALIGNED")
      (progn
(setq e10 (cdr (assoc 10 entBdata)))
(grdraw e10
(polar e10 (angle e10 value) (distance e10 value))
4
1
)
(setq entBdata (subst (cons cons1 (angle e10 value))
      (assoc cons1 entBdata)
      entBdata
       )
)
      )
    )



(setq itemAngle (rtd (cdr (assoc 50 (entget bENAME)))))
(setq itemXscale (cdr (assoc 41 (entget bENAME))))
(setq itemYscale (cdr (assoc 42 (entget bENAME))))
   
(if (> itemAngle 360.0)
  (setq itemAngle (- itemAngle 360.0))
)
   
(DBMANtext 252 (rtd cursorangle2) itemAngle itemXscale itemYscale insPblock itemLayer)
(entmod entBdata)

;--------------------------------------------------------------------
;the "attsync" command has been included here
;--------------------------------------------------------------------
(vl-cmdf "_.attsync" "_N" (cdr (assoc 2 (entget bENAME))))
;--------------------------------------------------------------------

)

(if (or
      (eq ToDo "MOVE")
      (eq ToDo "COPY")
    )
  (DBMANtextDI 254 (polar NBpoint (angle NBpoint cursorpoint) (/ (distance NBpoint cursorpoint) 2))
                     (distance NBpoint cursorpoint))
  )

 
(setq cursorpoint2 nil) 
)

hope this is what you need

nini007

  • Newt
  • Posts: 58
Hello,

I thank you for your message :-).
So I loaded the lisp DBMAN and your code, unfortunately it still does not work :cry:.
Is it because I have an AutoCAD 2018 version in French? :idea:
Or do I have to do a special manipulation? :idea:

Thank you for your help :-D
Best regards

Augusto

  • Newt
  • Posts: 75
You just have to include the "attsync" command inside the function that updates the blocks.
My autoCAD is in the English version and the program worked correctly. Unfortunately I can not test the French version.
Hope this helps.

Best regards,
Luís Augusto

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
ATTSYNC should not be necessary and could have undesired results; instead, the code should either change the ActiveX rotation property of the block reference (which will affect attributes), use the ActiveX rotate method (which will affect attributes), or modify the DXF data of each attribute reference (ATTRIB) entity at the same time as modifying that of the block reference (INSERT) entity.

nini007

  • Newt
  • Posts: 58
Hello Augusto,
thank you for your help :-)
The Rotate option works correctly was this option that interested me  :wink:

Thanks also to Lee mac for your comments  :-)

Best regards

Augusto

  • Newt
  • Posts: 75
ATTSYNC should not be necessary and could have undesired results; instead, the code should either change the ActiveX rotation property of the block reference (which will affect attributes), use the ActiveX rotate method (which will affect attributes), or modify the DXF data of each attribute reference (ATTRIB) entity at the same time as modifying that of the block reference (INSERT) entity.

Lee, thank you very much for sharing your knowledge with us.
I changed part of the code as indicated and now it is much better.
Code: [Select]
  ;suggested by Lee Mac
   (vla-put-Rotation (vlax-ename->vla-object SSblock) ibangle)
Best regards,
Luís Augusto

nini007

  • Newt
  • Posts: 58
Hello,
thank you for your message and a thank you to Lee Mac  :-)
I tested the lisp, unfortunately there is a small problem  :brow:
When I run the lisp with the command with "DBMAN" with the options, R and A, the texts turn at 180 ° automatically, so upside down ?
Is it possible that he does not turn around and correct that ?

Best regards

Augusto

  • Newt
  • Posts: 75
Could you attach your block so I can test?
It's working properly for me.  :oops:

nini007

  • Newt
  • Posts: 58
Hello,
You will find attached my file with the block.

thank you in advance :-)
Best regards

Augusto

  • Newt
  • Posts: 75
I do not know if I understood correctly.
Could you try again?
If not what you expected, unfortunately my chances have run out.
I hope I have helped you.

@LeeMac, thank you for putting so many wonders on your website.
I do not know what would become of me without his functions.  :smitten:
« Last Edit: July 26, 2018, 01:28:10 PM by Augusto »

nini007

  • Newt
  • Posts: 58
Hello,
Thank you for your help that seems to be good  :grinwink:
On the other hand, the other oprtions do not seem to work well. :-(
Resume this lisp and update it will be wise because it is very useful  :-)

thank you for all  :-)
Best regards

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
@LeeMac, thank you for putting so many wonders on your website.
I do not know what would become of me without his functions.  :smitten:

You're most welcome! Thank you for your kind words  :-)