Jump to content

vlax-put-property - How to find list of "property" and "arg"?


Recommended Posts

Posted

Hi guys,

I want to learn ActiveX.

For function vlax-put-property, I found the help link below.

https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-C56E4AF5-A763-4B9D-AB35-C863D02FB93B

 

Signature: (vlax-put-property obj      property arg)

Sample:    (vlax-put-property vlaobj 'Color         1)

 

I knew that 1 property is Color, and 1 is arg of that color.

But how can I find the whole properties which I could use, and its arg, too.

Thank you for your help!

image.thumb.png.2bd7c65354bbe6b121f54c583f3261a8.png

Posted

Can you attached example drawing 

  • Like 1
Posted
4 hours ago, saunambon654 said:

But how can I find the whole properties which I could use, and its arg, too.

 

This will output all values of a selected entity (RO) = Read Only and can't be changed.

;;----------------------------------------------------------------------------;;
;; Dump All Visual Lisp Methods and Properties for Selected Entity
(defun C:VDumpIt (/ ent)
  (while (setq ent (car (entsel "\nSelect Entity to Dump")))
    (vlax-Dump-Object (vlax-Ename->Vla-Object ent) t)
  )
  (princ)
)

 

Output will look something like this.

Quote


Select Entity to Dump
; IAcadLine 3d01b860 : TeighaX Interface of a single line segment
;
; Property values :
;
;   Angle (RO) = 0.368559514224635
;   Application (RO) = #<VLA-OBJECT IAcadApplication 000000002676E8A0>
;   color = 256
;   Database (RO) = #<VLA-OBJECT IAcadDatabase 000000003D2AD858>
;   Delta (RO) = (5.08441558441558 1.96363636363636 0.0)
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000003C91DAF8>
;   EndPoint = (8.74094550309503 5.27142857142857 0.0)
;   EntityName (RO) = "AcDbLine"
;   EntityType (RO) = NIL
;   Handle (RO) = "73"
;   HasExtensionDictionary (RO) = 0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000000003D4D7618>
;   Layer = "0"
;   Length (RO) = 5.45042655244918
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 1026207472
;   ObjectID32 (RO) = 1026207472
;   ObjectName (RO) = "AcDbLine"
;   OwnerID (RO) = 1018570272
;   OwnerID32 (RO) = 1018570272
;   PlotStyleName = "ByLayer"
;   StartPoint = (3.65652991867945 3.30779220779221 0.0)
;   Thickness = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 000000003D2AE178>
;   Visible = -1
;
; Methods supported :
;
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   Copy ()
;   Delete ()
;   Erase ()
;   GetBoundingBox (2)
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   Offset (1)
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()

 

  • Like 1
Posted

Actually, I would like to find the way to change color of all entities in a block to "Byblock".

I am using AutoCAD2007 and the command SETBYLAYER is not available.

Please find the CAD sample attachment.

image.thumb.png.86ce2e2ab63ddade9c2e719ed212ca49.png

Sample to learn ActiveX-231105.dwg

Posted

test @saunambon654

 

;;https://www.cadtutor.net/forum/topic/66770-help-for-creating-a-point-from-reference-block/
;;  Roy_043
(defun KGA_Conv_Pickset_To_ObjectList (ss / i ret)
  (if ss
    (repeat (setq i (sslength ss))
      (setq ret (cons (vlax-ename->vla-object (ssname ss (setq i (1- i)))) ret))
    )
  )
)

(defun GetLevel (nme blksObj / out)
  (vlax-for obj (vla-item blksObj nme)
    (cond
      (out);1
      ((= "AcDbBlockReference" (vla-get-objectname obj))
        (setq out (GetLevel (vla-get-name obj) blksObj))
      );3
      ((vla-put-color obj 0)
        
      );5
    );COND
  )
)

(defun c:testcolorByblock ( / blksObj doc pt spc ss)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq blksObj (vla-get-blocks doc))
  (vla-endundomark doc)
  (vla-startundomark doc)
  (if (setq ss (ssget '((0 . "INSERT") )))
    (progn
      (setq spc (vla-get-modelspace doc))
      (foreach obj (KGA_Conv_Pickset_To_ObjectList ss)
        
        (GetLevel (vla-get-name obj) blksObj)
      )
    )
  )
  (vla-endundomark doc)
  (vla-regen doc acAllViewports)
  (princ)
)

 

70.gif

Posted (edited)

Thank you @hosneyalaa,

There are some remaining objects which still have different color (element of dimension, character of Mtext...).

Could you upgrade to make EVERYTHING become "Byblock"? It mean if I change its color to red, EVERYTHING will be change to red.

 

image.thumb.png.75346b516e36753fd4b7bb6f89dd34c6.png

image.thumb.png.4c0dc1eafa15870a086792ab554c6dfb.png

image.thumb.png.c102b07230883a815cadb2685dc8e5e2.png

Edited by saunambon654
Posted

characters of mtext might be set within the text dialogue pop-up - you might need to use "strip Mtext" LISP to clear these, I can't remember on a Sunday if that also does dimension texts as well

Posted
7 hours ago, Steven P said:

characters of mtext might be set within the text dialogue pop-up - you might need to use "strip Mtext" LISP to clear these, I can't remember on a Sunday if that also does dimension texts as well

Thank you, Steve P.

Yes, I knew about "Strip Mtext". But you see, my sample dwg includes color of Mtext, Mtext of dimension, Dimension, leader too. So it is complicate for me, and I would really appreciate your help.

Btw, my zone time is GMT+7, normally I could read your comments after few hours late.

Posted (edited)

 

explode everything with nburst, and change the color with MA.

and a shout out to the person who drew this drawing. 😀

 

http://www.lee-mac.com/unformatstring.html

(defun c:test ( / ss index ent entl type1 typ2 obj tover )
  (setq ss (ssget '((0 . "MTEXT,DIMENSION"))))
  (setq index 0)
  (repeat (sslength ss)
    (setq ent (ssname ss index))
    (setq entl (entget ent))
    (setq type1 (cdr (assoc 0 entl)))
    (setq obj (vlax-ename->vla-object ent))
    (vlax-put-property obj 'Color 0)
    (cond 
      ((= type1 "MTEXT")
        (vlax-put-property obj 'textstring (LM:Unformat (vlax-get-property obj 'textstring) nil))
      )
      ((= type1 "DIMENSION")
        (vlax-put-property obj 'Color 0)
        (setq type2 (vlax-get-property obj 'objectname))
        (cond
          ((= type2 "AcDbAlignedDimension")
            (setq tover (vlax-get-property obj 'textoverride))
            (if (/= tover "") (vlax-put-property obj 'textoverride (LM:Unformat tover nil)))
            (vlax-put-property obj 'DimensionLineColor 0)
            (vlax-put-property obj 'ExtensionLineColor 0)
            (vlax-put-property obj 'TextColor 0)
          )
          ((= type2 "AcDbRadialDimension")
            (setq tover (vlax-get-property obj 'textoverride))
            (if (/= tover "") (vlax-put-property obj 'textoverride (LM:Unformat tover nil)))
            (vlax-put-property obj 'DimensionLineColor 0)
            (vlax-put-property obj 'TextColor 0)
          )
        )
      )
    )
    (setq index (+ index 1))
  )
  (princ)
)

 

Edited by exceed
Posted
27 minutes ago, exceed said:

 

explode everything with nburst, and change the color with MA.

and a shout out to the person who drew this drawing. 😀

Oh... this is sample dwg only. In fact my drawings have thousands of blocks and Xrefs, they are nested at multiple levels, and you will not want to do manual.

Posted (edited)
5 minutes ago, saunambon654 said:

Oh... this is sample dwg only. In fact my drawings have thousands of blocks and Xrefs, they are nested at multiple levels, and you will not want to do manual.

 

nburst ( http://www.lee-mac.com/upgradedburst.html ) can explode all of nested block to normal object in one time. 

 

Nevertheless, if you have to do this,

1. You can change the color of the layer change part of this link and refer to my code above.

 

2. You can use vl-catch-all-error-p to change the property to only be modified on objects that can be modified.

Edited by exceed
Posted

Oh... Block is a wonderful tool to control your drawing. Example you have 100 tables, each table have 4 chairs. With block, you can control only one table and one chair.

Explode entry drawing is one way to do, but if possible I would retain them all.

Posted
22 minutes ago, exceed said:

 

nburst ( http://www.lee-mac.com/upgradedburst.html ) can explode nested block to normal object in one time. 

 

Nevertheless, if you have to do this,

1. You can change the color of the layer change part of this link and refer to my code above.

 

2. You can use vl-catch-all-error-p to change the property to only be modified on objects that can be modified.

Thank you exceed,

I have tried to change block's color to byblock by:

1. Norm (from your recommend).

2. Edit_bloc_3.5 (from Gilecad).

3. Eq (from your recommend).

4. setblockcolour (Lee Mac - from https://www.cadtutor.net/forum/topic/51724-change-block-colour/)

Almost tools work well with single object or single object inside block. But there is difficult for color of MText and Dimesion in block.

If you have any tool which can work with my sample dwg, please help to solve.

Thank you very much for your help!

 

image.thumb.png.bd3a82571f37361364eeaa2c78f8af33.png

image.thumb.png.1db78c59de51d2666cef7eaca6e1f3b9.png

image.thumb.png.6a5dcb3d488a5bdb33ef21c5a5dc76bb.png

image.thumb.png.c8f04f87c4a853c7b244fc70bef37882.png

image.thumb.png.513a55a33937b5135913c79d303912e0.png

 

Posted (edited)

Since it is not an complete routine, but only a recipe,

the screenshot result is natural. 

 

1 hour ago, exceed said:
      ((= type1 "MTEXT")
        (vlax-put-property obj 'textstring (LM:Unformat (vlax-get-property obj 'textstring) nil))
      )
      ((= type1 "DIMENSION")
        (vlax-put-property obj 'Color 0)
        (setq type2 (vlax-get-property obj 'objectname))
        (cond
          ((= type2 "AcDbAlignedDimension")
            (setq tover (vlax-get-property obj 'textoverride))
            (if (/= tover "") (vlax-put-property obj 'textoverride (LM:Unformat tover nil)))
            (vlax-put-property obj 'DimensionLineColor 0)
            (vlax-put-property obj 'ExtensionLineColor 0)
            (vlax-put-property obj 'TextColor 0)
          )
          ((= type2 "AcDbRadialDimension")
            (setq tover (vlax-get-property obj 'textoverride))
            (if (/= tover "") (vlax-put-property obj 'textoverride (LM:Unformat tover nil)))
            (vlax-put-property obj 'DimensionLineColor 0)
            (vlax-put-property obj 'TextColor 0)
          )
        )
      )

merging these lines to eq's this part. 

match variable names and learn how to use them.

 

       (vlax-for ent blk_def
         (vla-put-layer ent "A-EQUIP")
         (vla-put-color ent 121)
         (vla-put-lineweight ent aclnwtbyblock)
         (vla-put-linetype ent "byblock")
         ) ;_ end of vlax-for

 

 

Edited by exceed

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...