subodh_gis Posted October 1, 2013 Posted October 1, 2013 Many a times it requires to show the same block with different angle and scale. Rotating each block to a required angle, and scaling it as required will take a lot of time so can we Insert Block in-between two Points in the angle and scale of points selection using Autolisp . I am using AutoCAD 2004. Thank You ! Quote
gS7 Posted October 1, 2013 Posted October 1, 2013 Try This . I Hope Its Help You ... Tested in 2004 version (defun c:Test(/ b ss e en xe ye ze r) ;Ganesh Shetty ;Match Block Rotation angle & Scale ;2013 (vl-load-com) (if (and (setq B (car (entsel"\nSelect Block:"))) (setq ss (ssget '((0 . "INSERT")))) ) (progn (setq e (vlax-ename->vla-object b)) (repeat (setq i (sslength ss)) (setq en (vlax-ename->vla-object (ssname ss (setq i (1- i))))) (setq XE (vla-get-XScaleFactor e) YE (vla-get-YScaleFactor e) ZE (vla-get-ZScaleFactor e) r (vla-get-Rotation e) ) (if (vlax-method-applicable-p en 'Rotate) (vla-put-rotation en r) ) (vla-put-XScaleFactor en XE) (vla-put-YScaleFactor en YE) (vla-put-ZScaleFactor en ZE) ) ) ) (princ)) Quote
subodh_gis Posted October 1, 2013 Author Posted October 1, 2013 @ Ganesh Shetty Thanks for quick reply sir What it will do sir? Its asking to select the block and object. Please explain how it will help me. Quote
satishrajdev Posted October 1, 2013 Posted October 1, 2013 Dear Subodh, R u want a lisp, that can insert block with specific rotation and scale??? or You want to change rotation and scale of existing block??? Quote
subodh_gis Posted October 1, 2013 Author Posted October 1, 2013 I want a lisp that can insert a perticular block with rotation and scale using two clicks only Quote
satishrajdev Posted October 1, 2013 Posted October 1, 2013 Here is a example for this, I hope this would help you :- (Defun c:test () (setq ent (car (entsel "\n Select Block :")) bkname (cdr (assoc 2 (entget ent))) rotp1 (getpoint "\n Specify 1st Rotation point :") rotp2 (getpoint "\n Specify 2nd Rotation point :") rot (angle rotp1 rotp2) scl (distance rotp1 rotp2) pnt (getpoint "\n Specify Point to Insert Block :") ) (command "insert" bkname "_scale" scl "_non" pnt rot) (princ) ) Quote
subodh_gis Posted October 1, 2013 Author Posted October 1, 2013 Thanks for quick reply Please see the link below http://www.youtube.com/watch?v=txel0pIRcdI I want a lisp just like that. Quote
gS7 Posted October 1, 2013 Posted October 1, 2013 @ Ganesh Shetty Thanks for quick reply sir What it will do sir? Its asking to select the block and object. Please explain how it will help me. Kindly find the attached Drawing file for Program Guide match block.dwg Quote
neophoible Posted October 1, 2013 Posted October 1, 2013 Are you saying that the insertion point of your BLOCK will match the midpoint of your two picked points? If so, then that will be an easy fix for the routine already offered. If the scale is simply the distance from one of the pick points to the calculated insertion point, then that should not be too difficult to add as well. Is that the scale factor you need? Quote
gS7 Posted October 2, 2013 Posted October 2, 2013 @subodh, Are You Going to Insert Different Types of Blocks ? Kindly attach Your Block Drawing.. We are Trying to Help You ,Don't be sad Quote
gS7 Posted October 2, 2013 Posted October 2, 2013 I found a Solution , 1.Make Sure Your Block Dimensions is 1mm x 1mm Size 2.Make Center Point is Your Block Insertion Point Codes. (defun c:Test(/ bname pt1 pt2 d ang mp) (if (and (setq bname(getstring "\nEnter Block Name To Insert:")) (setq pt1 (getpoint "\nPick First Rotation Point:")) (setq pt2 (getpoint "\nPick 2nd Rotation Point:")) ) (progn (if (not (Tblsearch "BLOCK" bname)) (princ "\nBlock Not found in Drawing!") (progn (setq d (/ (distance pt1 pt2) 2.0)) (setq ang (angle pt1 pt2)) (setq mp (polar pt1 ang d)) (command "_INSERT" bname "_SCALE" (distance pt1 pt2) "_non" mp (angtos ang)) ) ) ) ) (princ)) Here , Find the attachment Drawing .. your Block Should Be Like This Myblock.dwg Quote
javid Posted March 5, 2014 Posted March 5, 2014 Hello dear friends:) I read this useful post but I have a problem with this lisp... As I tried to changing this routine for myself and i didn't succeed! I need your help to have another lisp withoput changing my block scale and also without asking my block name each times i want to use this lisp (I want to write my blockname directly into that lisp). So, I need to use just one block in to my drawing only with changing it's rotation. I will be thankful if anybody help me to solve my problem. Quote
JamCAD Posted March 5, 2014 Posted March 5, 2014 javid, here is a very basic version for you to try. It will only insert the block if it already exists in the drawing (defun c:blockmp (/ blknme p1 p2 ang) (setq blknme "Name of block") ;Name of the block (setq p1 (getpoint "\nPick first point: ")) (setq p2 (getpoint p1 "\nPick second point: ")) (setq ang (angtos (angle p1 p2))) ;Calculates the angle between points one and two (command "_Insert" blknme "_mtp" p1 p2 1 "" ang) ) 1 Quote
javid Posted March 8, 2014 Posted March 8, 2014 Hi dear j0nat Thank you so much for your useful help It's working for me anf was so helpful Thanks alot:) Quote
svippala Posted July 10, 2019 Posted July 10, 2019 @JamCAD Thanks for coding in the same code we adding scale(up/down) option is its possible (defun c:blockmp (/ blknme p1 p2 ang) (setq blknme "Name of block") ;Name of the block (setq p1 (getpoint "\nPick first point: ")) (setq p2 (getpoint p1 "\nPick second point: ")) (setq ang (angtos (angle p1 p2))) ;Calculates the angle between points one and two (command "_Insert" blknme "_mtp" p1 p2 1 "" ang) ) Quote
Recommended Posts
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.