Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Check uniform scale blocks

11 REPLIES 11
Reply
Message 1 of 12
itmanagement
1440 Views, 11 Replies

Check uniform scale blocks

I have written a lisp routine to insert blocks in drawings The syntax used is:-

(command "insert" ins_point x_scale y_scale rotation att1 att2)

This was working fine but problems started to occur on certain files. The y scale was being used for the rotation value and the rotation value was being used for the first attribute value. On investigation I found that the blocks in these files had been set to uniform scale.

Is there a way I can change the uniform scale for the block before invoking the insert command or checking for uniform scale and running different insert commands depending on the result of the check?

I have tried running a tblsearch on the block with it set uniformly and non uniformly and cannot find a difference. I have also checked the codes on the block insertions by running (entget (car (entesl)) in both files but cannot find a difference.
11 REPLIES 11
Message 2 of 12
itmanagement
in reply to: itmanagement

I have found a workaround for the problem.

I wblocked the block. Went into the file and changed it to non uniform scale.

In my code I now do an insert = and pull in the new block which changes the existing block from uniform scale to non uniform.
Message 3 of 12
Anonymous
in reply to: itmanagement

Belated reply...

You can check whether a block definition allows non-uniform scaling or not by looking
at the BlockScaling property. And you can change that property if need be.

Joe Burke
Message 4 of 12
itmanagement
in reply to: itmanagement

Thanks Joe.

Sorry if I'm being a bit slow here but what is the command/syntax for this. I've looked through the developers help file and not found anything.
Message 5 of 12
Anonymous
in reply to: itmanagement

Assuming the is known and it is a valid block name, something like this:

(setq *blocks* (vla-get-Blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
(setq blkdef (vla-item *blocks* ))
(if (= 0 (vlax-get blkdef 'BlockScaling))
(print "block may be non-uniormly scaled.")
(print "block may not be non-uniormly scaled.")
)
Message 6 of 12
itmanagement
in reply to: itmanagement

Thanks Joe.
Message 7 of 12
Anonymous
in reply to: itmanagement

You're welcome.
Message 8 of 12
jcourtne
in reply to: itmanagement

I was not able to get the posted solution to work.

Doing a vlax-dump object on my block I do not see the scaled uniformly property either.

This is the result of a dump from a dynamic block that is uniformly scaled. However, sometimes i need to know whether the block i'm inserting is uniformly scaled before it is even defined on the drawing. Meaning i'll have to check that blocks dwg file from running lisp. Thats way beyond what i can do currently. 

If anyone comes up with something else please post. 🙂

 

; IAcadBlockReference2: AutoCAD Block Reference Interface
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00000001406191d8>
;   Document (RO) = #<VLA-OBJECT IAcadDocument 000000002c5b40e0>
;   EffectiveName (RO) = "BD_EQ"
;   EntityTransparency = "ByLayer"
;   Handle (RO) = "316"
;   HasAttributes (RO) = -1
;   HasExtensionDictionary (RO) = -1
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0000000031d0f4c8>
;   InsertionPoint = (21.25 22.125 0.0)
;   InsUnits (RO) = "Inches"
;   InsUnitsFactor (RO) = 1.0
;   IsDynamicBlock (RO) = -1
;   Layer = "0"
;   Linetype = "ByLayer"
;   LinetypeScale = 1.0
;   Lineweight = -1
;   Material = "ByLayer"
;   Name = "*U4"
;   Normal = (0.0 0.0 1.0)
;   ObjectID (RO) = 42
;   ObjectID32 (RO) = 42
;   ObjectName (RO) = "AcDbBlockReference"
;   OwnerID (RO) = 43
;   OwnerID32 (RO) = 43
;   PlotStyleName = "ByLayer"
;   Rotation = 0.0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 0000000031d0f9a0>
;   Visible = -1
;   XEffectiveScaleFactor = 1.0
;   XScaleFactor = 1.0
;   YEffectiveScaleFactor = 1.0
;   YScaleFactor = 1.0
;   ZEffectiveScaleFactor = 1.0
;   ZScaleFactor = 1.0
; Methods supported:
;   ArrayPolar (3)
;   ArrayRectangular (6)
;   ConvertToAnonymousBlock ()
;   ConvertToStaticBlock (1)
;   Copy ()
;   Delete ()
;   Explode ()
;   GetAttributes ()
;   GetBoundingBox (2)
;   GetConstantAttributes ()
;   GetDynamicBlockProperties ()
;   GetExtensionDictionary ()
;   GetXData (3)
;   Highlight (1)
;   IntersectWith (2)
;   Mirror (2)
;   Mirror3D (3)
;   Move (2)
;   ResetBlock ()
;   Rotate (2)
;   Rotate3D (3)
;   ScaleEntity (2)
;   SetXData (2)
;   TransformBy (1)
;   Update ()

Message 9 of 12
Kent1Cooper
in reply to: jcourtne


@jcourtne wrote:

... sometimes i need to know whether the block i'm inserting is uniformly scaled before it is even defined on the drawing. Meaning i'll have to check that blocks dwg file from running lisp. ....


If the Block is going to be inserted at uniform scales, and the only reason to check on whether it's defined for uniform scaling is to know whether to supply both X and Y scale factors in an Insert command, then you can eliminate the issue by using the Scale option in the command.  It asks for a scale factor, and applies the same one to all axes, so you can supply it once, and it doesn't matter how many it would ask for if you weren't using that option:

 

(command "_.insert" "_scale" YourScale YourInsertionPoint ....

Kent Cooper, AIA
Message 10 of 12
dbroad
in reply to: jcourtne

Kent is right.  It is easy to avoid the issue when all scale factors are the same.

 

You were checking the block reference object (an insert), not a block object.  This is one way to check if a block is uniformly scaled.

(vl-load-com)
;;DCB Returns true if the block is defined with
;;a uniform scale.
(defun isuniform (blockname)
  (if (tblobjname "block" blockname)
    (= acUniform
       (vla-get-blockscaling
	 (vla-item
	   (vla-get-blocks
	     (vla-get-activedocument
	       (vlax-get-acad-object)
	       )
	     )
	   blockname
	   )
	 )
       )
    )
  )

 

Architect, Registered NC, VA, SC, & GA.
Message 11 of 12
jcourtne
in reply to: Kent1Cooper

Thank you for pointing that out. That IS exactly why i wanted to know. I am now going back and revising how i'm inserting blocks in all my code to make sure that I will not contiue to have that problem. Here is a completed example of my workaround if any reader needs explicitly.

(vl-cmdf "-insert" (strcat path blockname) "S" 1 "R" 0 point)

 

Honestly, I don't know why i had never tried options other than just typing the values in for each question.

Thanks again.

Message 12 of 12
Kent1Cooper
in reply to: jcourtne

You're welcome,  I was going to suggest that 1 is the default, because 1 is always the default for X and Y scale factors [it doesn't remember the scales you used before], so you could just use "" for Enter instead of specifying 1.  But in a quick test, it turns out that the Scale option doesn't default to 1 [nor remember the scale you used before], so you do need to provide a specific value.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost